选择在 Yeoman 中生成命令的位置

Choose where to spawn a command in Yeoman

我正在构建一个生成器,最后我需要在我的应用程序的某个目录中 npm install,我试过类似的东西:

this.spawnCommandSync('cd', [this.destinationRoot() + '/my/folder'])
this.spawnCommandSync('npm', ['install'])

但是没用。

并且 npm install 不能在不同的目录中调用,也不能在任何 yeoman install mixins.

中调用

传递选项 cwd - 就像 https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options