Skip to content

Commit

Permalink
fix(gen:app): fix insight askPermission
Browse files Browse the repository at this point in the history
fixes #1889
  • Loading branch information
Awk34 committed May 15, 2016
1 parent be5ace9 commit f6f1fb6
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/generators/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import fs from 'fs';
import path from 'path';
import Promise from 'bluebird';
import { runCmd } from '../util';
import chalk from 'chalk';
import {Base} from 'yeoman-generator';
Expand Down Expand Up @@ -40,25 +41,32 @@ export class Generator extends Base {

// init shared generator properies and methods
const genBasePromise = genBase(this);
let promises = [genBasePromise];

if(process.env.CI) {
insight.optOut = true;
} else if(insight.optOut === undefined) {
promises.push(new Promise((resolve, reject) => {
insight.askPermission(null, (err, optIn) => {
if(err) return reject(err);
else return resolve(optIn);
});
}));
}

insight.track('generator', this.rootGeneratorVersion());
this.nodeVersion = semver.clean(process.version);
this.semver = semver;
insight.track('node', this.nodeVersion);
insight.track('platform', process.platform);

if(process.env.CI) {
insight.optOut = true;
} else if(insight.optOut === undefined) {
insight.askPermission(null, cb);
}

const npmVersionPromise = runCmd('npm --version').then(stdout => {
this.npmVersion = stdout.toString().trim();
return insight.track('npm', this.npmVersion);
});
promises.push(npmVersionPromise);

return Promise.all([genBasePromise, npmVersionPromise]);
return Promise.all(promises);
},
info: function () {
this.log(this.yoWelcome);
Expand Down

0 comments on commit f6f1fb6

Please sign in to comment.