Skip to content

Commit af10918

Browse files
committed
run api generator after app is booted
resolve strongloop/loopback-boot#291
1 parent a12d373 commit af10918

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

export-api-def/index.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,23 @@ module.exports = class ExportAPIDefGenerator extends ActionsMixin(yeoman) {
3737
var app = require(this.destinationRoot());
3838
var apiDef = apiGenerator.getApiDef(app, options);
3939

40-
// Print to console if no output file specified.
41-
if (filePath) {
42-
mkdirp.sync(path.dirname(filePath));
43-
fs.writeFileSync(filePath, apiDef);
40+
if (app.booting !== false) {
41+
app.on('booted', runGenerator);
4442
} else {
45-
process.stdout.write(apiDef);
43+
runGenerator();
4644
}
4745

48-
// Kill app if still alive
49-
setTimeout(process.exit, 100);
46+
function runGenerator() {
47+
// Print to console if no output file specified.
48+
if (filePath) {
49+
mkdirp.sync(path.dirname(filePath));
50+
fs.writeFileSync(filePath, apiDef);
51+
} else {
52+
process.stdout.write(apiDef);
53+
}
54+
55+
// Kill app if still alive
56+
setTimeout(process.exit, 100);
57+
}
5058
}
5159
};

0 commit comments

Comments
 (0)