UNPKG

@enplug/scripts

Version:
29 lines (24 loc) 716 B
const loadDevPrivateFile = require('./loadDevPrivateFile'); /** * Looks up `dev.private.json` up to two directories above. * @param {string} env `staging` or `dev` */ function getEnvToken(env) { let devPrivateFile; try { devPrivateFile = loadDevPrivateFile('../'); } catch (e) { devPrivateFile = loadDevPrivateFile('../../'); } // Production omitted by design. Do not add. if (devPrivateFile) { if (env === 'staging') { return devPrivateFile.staging_auth_token; } else if (env === 'dev') { return devPrivateFile.dev_auth_token; } } else { console.error(`Error finding/parsing ${chalk.default.yellow('dev.private.json')}`); } } module.exports = getEnvToken;