我正在编写一个 Yeoman 生成器,我想复制一个目录。您可以在下面找到代码。它工作正常,但是,在复制完成后,我想执行进一步的操作,如“npm install”。 由于复制是异步完成的,因此在复制所有文件之前执行“npm install”。我如何才能等到所有复制操作完成?
this.expandFiles('**', {
cwd: this.sourceRoot(),
dot: true
}).forEach(function (el) {
this.copy(el, el);
}, this);
最佳答案
使用 .on
调用链 this.copy
并在 'end'
事件上运行您的函数。
this.copy(el, el)
.on('end', function() {
console.log("Copy is complete");
});
关于javascript - 如何在 Yeoman 中等到复制操作完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24550663/