leran cli 的源代码 https://github.com/lerna/lerna/blob/main/core/command/index.js#L45
这个 command 的 constructor 里面,
- 这种执行方式,是同步的么?
let chain = Promise.resolve();
chain = chain.then(() => {
this.project = new Project(argv.cwd);
});
chain = chain.then(() => this.configureEnvironment());
chain = chain.then(() => this.configureOptions());
chain = chain.then(() => this.configureProperties());
chain = chain.then(() => this.configureLogging());
chain = chain.then(() => this.runValidations());
chain = chain.then(() => this.runPreparations());
chain = chain.then(() => this.runCommand());
- 然后上面 1 中的代码,外面套了一层 let runner = new Promise((resolve, reject) => { ... } 后面继续 runer.then(...) 这个是同步还是异步?
- command 的 constructor 是同步还是异步?
- 该类 Command 的方法,runCommand()呢?
runCommand() {
return Promise.resolve()
.then(() => this.initialize())
.then((proceed) => {
if (proceed !== false) {
return this.execute();
}
// early exits set their own exitCode (if non-zero)
});
}
看得我好迷糊,也都没有添加 async 关键。
求指点。
谢谢!