* @private * @method run * @param {Promise } environmentPromiseHash * @return {Promise}
(environmentPromiseHash)
| 119 | * @return {Promise} |
| 120 | */ |
| 121 | async run(environmentPromiseHash) { |
| 122 | if (environmentPromiseHash === undefined) { |
| 123 | return Promise.reject(new Error('Unable to execute "run" command without environment argument')); |
| 124 | } |
| 125 | let shutdownOnExit = null; |
| 126 | |
| 127 | let environment = (this._environment = await hash(environmentPromiseHash)); |
| 128 | |
| 129 | try { |
| 130 | let args = environment.cliArgs.slice(); |
| 131 | let commandName = args.shift(); |
| 132 | let commandArgs = args; |
| 133 | let helpOptions; |
| 134 | |
| 135 | let commandLookupCreationToken = heimdall.start('lookup-command'); |
| 136 | |
| 137 | let command = this.maybeMakeCommand(commandName, commandArgs); |
| 138 | |
| 139 | commandLookupCreationToken.stop(); |
| 140 | |
| 141 | getOptionArgs('--verbose', commandArgs).forEach((arg) => { |
| 142 | process.env[`EMBER_VERBOSE_${arg.toUpperCase()}`] = 'true'; |
| 143 | }); |
| 144 | |
| 145 | logger.info('command: %s', commandName); |
| 146 | |
| 147 | let instrumentation = this.instrumentation; |
| 148 | let onCommandInterrupt; |
| 149 | |
| 150 | let runPromise = Promise.resolve().then(async () => { |
| 151 | let resultOrExitCode; |
| 152 | |
| 153 | try { |
| 154 | instrumentation.stopAndReport('init'); |
| 155 | |
| 156 | try { |
| 157 | instrumentation.start('command'); |
| 158 | |
| 159 | loggerTesting.info('cli: command.beforeRun'); |
| 160 | onProcessInterrupt.addHandler(onCommandInterrupt); |
| 161 | |
| 162 | await command.beforeRun(commandArgs); |
| 163 | |
| 164 | loggerTesting.info('cli: command.validateAndRun'); |
| 165 | |
| 166 | resultOrExitCode = await command.validateAndRun(commandArgs); |
| 167 | } finally { |
| 168 | instrumentation.stopAndReport('command', commandName, commandArgs); |
| 169 | |
| 170 | onProcessInterrupt.removeHandler(onCommandInterrupt); |
| 171 | } |
| 172 | } finally { |
| 173 | instrumentation.start('shutdown'); |
| 174 | shutdownOnExit = function () { |
| 175 | instrumentation.stopAndReport('shutdown'); |
| 176 | }; |
| 177 | } |
| 178 |
no test coverage detected