rejoice icon indicating copy to clipboard operation
rejoice copied to clipboard

Question - hidden feature rejoice supports env variable replacement?

Open ambrons opened this issue 11 years ago • 1 comments

So I was looking through the source trying to trace down how to setup our modules to work both in development and in production where the paths for plugins can be drastically different. Ideally using the -p option should take care of this.

However while I was looking I found this segment of code

internals.parseEnv = function (manifest) {

    if (!manifest ||
        typeof manifest !== 'object') {

        return;
    }

    Object.keys(manifest).forEach(function (key) {

        var value = manifest[key];
        if (typeof value === 'string' &&
            value.indexOf('$env.') === 0) {

            manifest[key] = process.env[value.slice(5)];
        }
        else {
            internals.parseEnv(value);
        }
    });
};

This appears to search for keys in the manifest file that start with $env. and does substitution on a key with a value specified in the process environment. Is this documented somewhere or did I miss it?

ambrons avatar Sep 25 '15 13:09 ambrons

I believe this is part of the a previous version. It used to be when it was just within hapi, you could start it up --filter.env=key which was like the confidence setup. I think most people generate confidence first. I am not entirely sure people use this, as it is a bit undocumented at this point. Now that rejoice supports just plain javascript I am not sure this is entirely useful anymore, and it should likely be cleaned up instead and be a part of a major version. I'll keep this open and see if others have strong opinions on the matter.

lloydbenson avatar Sep 25 '15 14:09 lloydbenson