我想在Yeoman发电机中使用Promise。但是我不明白为什么我的承诺在她.then
打电话时是不确定的:
_initDockerConfig() {
console.log(``);
console.log(`Init Docker config.`);
return new Promise((resolve, reject) => {
try {
this.fs.copyTpl(
this.templatePath(`docker`),
this.destinationPath(`app/config/docker`)
);
resolve();
} catch(error) {
reject(error);
}
});
}
当我打电话给我的方法时:
_installSymfony() {
return exec(`php -r "readfile(\'https://symfony.com/installer\');" > symfony`)
.then(() => {
console.log('');
console.log(chalk.green('Download symfony.'));
return exec(`php symfony new ${slugify(this.appName)}`);
})
.then(() => {
return exec(`mv ./${slugify(this.appName)}/* ./`);
})
.then(() => {
return exec(`rm symfony`);
})
.then(() => {
return exec(`rm -rf ${slugify(this.appName)}`);
})
.then(() => {
console.log(this._initDockerConfig()); // return Promise { undefined }
});
}
有人打电话给我帮忙吗?
谢谢!