MCPcopy
hub / github.com/dotenvx/dotenvx / run

Function run

src/cli/actions/run.js:49–169  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47}
48
49async 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 }

Callers

nothing calls this directly

Calls 11

noArmorMethod · 0.95
normalizeArmorAliasesFunction · 0.85
createSpinnerFunction · 0.85
conventionsFunction · 0.85
determineFunction · 0.85
catchAndLogFunction · 0.85
executeCommandFunction · 0.85
uniqueInjectedKeysFunction · 0.70

Tested by

no test coverage detected