yeoman-environment 2.3.0 → 2.3.4

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.
@@ -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).
@@ -357,6 +376,8 @@ class Environment extends EventEmitter {
357
376
  const Generator = this.get(namespace);
358
377
 
359
378
  if (typeof Generator !== 'undefined' && typeof Generator.default === 'function') {
379
+ Generator.default.resolved = Generator.resolved;
380
+ Generator.default.namespace = Generator.namespace;
360
381
  return this.instantiate(Generator.default, options);
361
382
  }
362
383
 
@@ -453,7 +474,9 @@ class Environment extends EventEmitter {
453
474
  return console.log(generator.help());
454
475
  }
455
476
 
456
- return generator.run(done);
477
+ const _callbackWrapper = callbackWrapper(generator, done);
478
+
479
+ return generator.run(_callbackWrapper);
457
480
  }
458
481
 
459
482
  /**
package/lib/resolver.js CHANGED
@@ -42,7 +42,7 @@ resolver.lookup = function (cb) {
42
42
  }
43
43
 
44
44
  for (const pattern of patterns) {
45
- for (const filename of globby.sync('*/index.js', {cwd: pattern, absolute: true})) {
45
+ for (const filename of globby.sync('*/index.js', {cwd: pattern, absolute: true, deep: 1})) {
46
46
  this._tryRegistering(filename);
47
47
  }
48
48
  }
@@ -73,9 +73,24 @@ resolver.findGeneratorsIn = function (searchPaths) {
73
73
  // restricted folders.
74
74
  try {
75
75
  modules = modules.concat(globby.sync(
76
- ['generator-*', '@*/generator-*'],
77
- {cwd: root, onlyFiles: false, absolute: true}
76
+ ['generator-*'],
77
+ {cwd: root, onlyFiles: false, absolute: true, deep: 0}
78
78
  ));
79
+
80
+ // To limit recursive lookups into non-namespace folders within globby,
81
+ // fetch all namespaces in root, then search each namespace separately
82
+ // for generator modules
83
+ const namespaces = globby.sync(
84
+ ['@*'],
85
+ {cwd: root, onlyFiles: false, absolute: true, deep: 0}
86
+ );
87
+
88
+ for (const namespace of namespaces) {
89
+ modules = modules.concat(globby.sync(
90
+ ['generator-*'],
91
+ {cwd: namespace, onlyFiles: false, absolute: true, deep: 0}
92
+ ));
93
+ }
79
94
  } catch (err) {
80
95
  debug('Could not access %s (%s)', root, err);
81
96
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yeoman-environment",
3
- "version": "2.3.0",
3
+ "version": "2.3.4",
4
4
  "description": "Handles the lifecyle and bootstrapping of generators in a specific environment",
5
5
  "homepage": "http://yeoman.io",
6
6
  "author": "Yeoman",
@@ -28,37 +28,35 @@
28
28
  "test": "nyc mocha",
29
29
  "doc": "jsdoc -c ./jsdoc.json ./readme.md",
30
30
  "benchmark": "matcha benchmark/**",
31
- "prepublish": "nsp check",
32
31
  "coverage": "nyc report --reporter=text-lcov | coveralls"
33
32
  },
34
33
  "dependencies": {
35
- "chalk": "^2.1.0",
34
+ "chalk": "^2.4.1",
36
35
  "cross-spawn": "^6.0.5",
37
36
  "debug": "^3.1.0",
38
- "diff": "^3.3.1",
37
+ "diff": "^3.5.0",
39
38
  "escape-string-regexp": "^1.0.2",
40
39
  "globby": "^8.0.1",
41
40
  "grouped-queue": "^0.3.3",
42
- "inquirer": "^5.2.0",
41
+ "inquirer": "^6.0.0",
43
42
  "is-scoped": "^1.0.0",
44
43
  "lodash": "^4.17.10",
45
- "log-symbols": "^2.1.0",
44
+ "log-symbols": "^2.2.0",
46
45
  "mem-fs": "^1.1.0",
47
46
  "strip-ansi": "^4.0.0",
48
47
  "text-table": "^0.2.0",
49
- "untildify": "^3.0.2"
48
+ "untildify": "^3.0.3"
50
49
  },
51
50
  "devDependencies": {
52
- "coveralls": "^3.0.1",
51
+ "coveralls": "^3.0.2",
53
52
  "jsdoc": "^3.5.5",
54
53
  "matcha": "^0.7.0",
55
- "mocha": "^5.1.1",
56
- "nsp": "^3.2.1",
57
- "nyc": "^11.7.3",
58
- "sinon": "^5.0.7",
59
- "sinon-test": "^2.1.3",
60
- "xo": "^0.18.1",
61
- "yeoman-assert": "^3.0.0",
54
+ "mocha": "^5.2.0",
55
+ "nyc": "^11.9.0",
56
+ "sinon": "^5.1.1",
57
+ "sinon-test": "^2.2.1",
58
+ "xo": "^0.18.2",
59
+ "yeoman-assert": "^3.1.1",
62
60
  "yeoman-generator": "^2.0.5"
63
61
  },
64
62
  "xo": {