@method validateAndRun @return {Promise}
(args)
| 268 | @return {Promise} |
| 269 | */ |
| 270 | async validateAndRun(args) { |
| 271 | let commandOptions = this.parseArgs(args); |
| 272 | |
| 273 | // If the `help` option was passed, resolve with `callHelp` to call the `help` command: |
| 274 | if (commandOptions && (commandOptions.options.help || commandOptions.options.h)) { |
| 275 | logger.info(`${this.name} called with help option`); |
| 276 | |
| 277 | return 'callHelp'; |
| 278 | } |
| 279 | |
| 280 | if (commandOptions === null) { |
| 281 | throw new SilentError(); |
| 282 | } |
| 283 | |
| 284 | if (this.works === 'outsideProject' && this.isWithinProject) { |
| 285 | throw new SilentError(`You cannot use the ${chalk.green(this.name)} command inside an ember-cli project.`); |
| 286 | } |
| 287 | |
| 288 | if (this.works === 'insideProject') { |
| 289 | if (!this.project.hasDependencies()) { |
| 290 | if (!this.isWithinProject && !this.project.isEmberCLIAddon()) { |
| 291 | throw new SilentError( |
| 292 | `You have to be inside an ember-cli project to use the ${chalk.green(this.name)} command.` |
| 293 | ); |
| 294 | } |
| 295 | |
| 296 | let installCommand = await determineInstallCommand(this.project.root); |
| 297 | |
| 298 | throw new SilentError( |
| 299 | `Required packages are missing, run \`${installCommand}\` from this directory to install them.` |
| 300 | ); |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | let detector = new WatchDetector({ |
| 305 | ui: this.ui, |
| 306 | childProcess: { execSync }, |
| 307 | fs, |
| 308 | watchmanSupportsPlatform: /^win/.test(process.platform), |
| 309 | cache, |
| 310 | root: this.project.root, |
| 311 | }); |
| 312 | |
| 313 | let options = commandOptions.options; |
| 314 | |
| 315 | if (this.hasOption('watcher') || process.env.EMBROIDER_PREBUILD) { |
| 316 | // Do stuff to try and provide a good experience when it comes to file watching: |
| 317 | let watchPreference = detector.findBestWatcherOption(options); |
| 318 | |
| 319 | this.project._watchmanInfo = watchPreference.watchmanInfo; |
| 320 | options.watcher = watchPreference.watcher; |
| 321 | } |
| 322 | |
| 323 | return this.run(options, commandOptions.args); |
| 324 | }, |
| 325 | |
| 326 | /** |
| 327 | Reports if the given command has a command line option by a given name |
nothing calls this directly
no test coverage detected
searching dependent graphs…