yeoman-environment 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/environment.js +22 -1
- package/package.json +1 -1
package/lib/environment.js
CHANGED
|
@@ -31,6 +31,25 @@ function splitArgsFromString(argsString) {
|
|
|
31
31
|
return result;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Wrap callback so it can't get called twice
|
|
36
|
+
*/
|
|
37
|
+
const callbackWrapper = (generator, done) => {
|
|
38
|
+
if (!done) {
|
|
39
|
+
return _.noop();
|
|
40
|
+
}
|
|
41
|
+
let callbackHandled = false;
|
|
42
|
+
const callback = err => {
|
|
43
|
+
if (!callbackHandled) {
|
|
44
|
+
callbackHandled = true;
|
|
45
|
+
done(err);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
// If error was thrown, make sure it is handled and only once
|
|
49
|
+
generator.on('error', callback);
|
|
50
|
+
return callback;
|
|
51
|
+
};
|
|
52
|
+
|
|
34
53
|
/**
|
|
35
54
|
* `Environment` object is responsible of handling the lifecyle and bootstrap
|
|
36
55
|
* of generators in a specific environment (your app).
|
|
@@ -453,7 +472,9 @@ class Environment extends EventEmitter {
|
|
|
453
472
|
return console.log(generator.help());
|
|
454
473
|
}
|
|
455
474
|
|
|
456
|
-
|
|
475
|
+
const _callbackWrapper = callbackWrapper(generator, done);
|
|
476
|
+
|
|
477
|
+
return generator.run(_callbackWrapper);
|
|
457
478
|
}
|
|
458
479
|
|
|
459
480
|
/**
|