()
| 47 | } |
| 48 | |
| 49 | async function run () { |
| 50 | const options = normalizeDotenvConfigConvention(normalizeDotenvConfigQuiet(normalizeArmorAliases(this.opts()))) |
| 51 | |
| 52 | let commandArgs = this.args |
| 53 | if (commandArgs.length < 1) { |
| 54 | commandArgs = inferCommandArgsFromProcessArgv(process.argv) |
| 55 | } |
| 56 | |
| 57 | const spinner = await createSpinner({ ...options, text: 'injecting' }) |
| 58 | |
| 59 | logger.debug(`options: ${JSON.stringify(options)}`) |
| 60 | logger.debug(`process command [${commandArgs.join(' ')}]`) |
| 61 | |
| 62 | const ignore = options.ignore || [] |
| 63 | |
| 64 | const sesh = new Session() |
| 65 | const noArmor = options.armor === false || (!options.token && (await sesh.noArmor())) |
| 66 | |
| 67 | if (commandArgs.length < 1) { |
| 68 | if (spinner) spinner.stop() |
| 69 | |
| 70 | const hasSeparator = process.argv.indexOf('--') !== -1 |
| 71 | |
| 72 | if (hasSeparator) { |
| 73 | logger.error('missing command after [dotenvx run --]. try [dotenvx run -- yourcommand]') |
| 74 | } else { |
| 75 | const realExample = options.envFile[0] || '.env' |
| 76 | logger.error(`ambiguous command due to missing '--' separator. try [dotenvx run -f ${realExample} -- yourcommand]`) |
| 77 | } |
| 78 | |
| 79 | process.exit(1) |
| 80 | } |
| 81 | |
| 82 | try { |
| 83 | let envs = [] |
| 84 | // handle shorthand conventions - like --convention=nextjs |
| 85 | if (options.convention) { |
| 86 | envs = conventions(options.convention).concat(this.envs) |
| 87 | } else { |
| 88 | envs = this.envs |
| 89 | } |
| 90 | envs = determine(envs, process.env) |
| 91 | |
| 92 | const { |
| 93 | processedEnvs, |
| 94 | readableFilepaths |
| 95 | } = await envsResolver({ |
| 96 | envs, |
| 97 | overload: options.overload, |
| 98 | processEnv: process.env, |
| 99 | envKeysFile: options.envKeysFile, |
| 100 | noArmor, |
| 101 | token: options.token, |
| 102 | command: commandArgs, |
| 103 | onStatus: (text) => { |
| 104 | if (spinner && text) { |
| 105 | spinner.text = text |
| 106 | } |
nothing calls this directly
no test coverage detected