|
2 | 2 |
|
3 | 3 | import fs from 'fs';
|
4 | 4 | import path from 'path';
|
| 5 | +import Promise from 'bluebird'; |
5 | 6 | import { runCmd } from '../util';
|
6 | 7 | import chalk from 'chalk';
|
7 | 8 | import {Base} from 'yeoman-generator';
|
@@ -40,25 +41,32 @@ export class Generator extends Base {
|
40 | 41 |
|
41 | 42 | // init shared generator properies and methods
|
42 | 43 | const genBasePromise = genBase(this);
|
| 44 | + let promises = [genBasePromise]; |
| 45 | + |
| 46 | + if(process.env.CI) { |
| 47 | + insight.optOut = true; |
| 48 | + } else if(insight.optOut === undefined) { |
| 49 | + promises.push(new Promise((resolve, reject) => { |
| 50 | + insight.askPermission(null, (err, optIn) => { |
| 51 | + if(err) return reject(err); |
| 52 | + else return resolve(optIn); |
| 53 | + }); |
| 54 | + })); |
| 55 | + } |
43 | 56 |
|
44 | 57 | insight.track('generator', this.rootGeneratorVersion());
|
45 | 58 | this.nodeVersion = semver.clean(process.version);
|
46 | 59 | this.semver = semver;
|
47 | 60 | insight.track('node', this.nodeVersion);
|
48 | 61 | insight.track('platform', process.platform);
|
49 | 62 |
|
50 |
| - if(process.env.CI) { |
51 |
| - insight.optOut = true; |
52 |
| - } else if(insight.optOut === undefined) { |
53 |
| - insight.askPermission(null, cb); |
54 |
| - } |
55 |
| - |
56 | 63 | const npmVersionPromise = runCmd('npm --version').then(stdout => {
|
57 | 64 | this.npmVersion = stdout.toString().trim();
|
58 | 65 | return insight.track('npm', this.npmVersion);
|
59 | 66 | });
|
| 67 | + promises.push(npmVersionPromise); |
60 | 68 |
|
61 |
| - return Promise.all([genBasePromise, npmVersionPromise]); |
| 69 | + return Promise.all(promises); |
62 | 70 | },
|
63 | 71 | info: function () {
|
64 | 72 | this.log(this.yoWelcome);
|
|
0 commit comments