Skip to content

Commit eb0f188

Browse files
committed
run rootcheck before anything else
especially before insight and update-notifier
1 parent 485c972 commit eb0f188

File tree

2 files changed

+39
-40
lines changed

2 files changed

+39
-40
lines changed

.jshintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"eqeqeq": true,
77
"eqnull": true,
88
"immed": true,
9-
"latedef": true,
109
"newcap": true,
1110
"noarg": true,
1211
"undef": true,
@@ -16,5 +15,6 @@
1615
"indent": 2,
1716
"white": true,
1817
"quotmark": "single",
19-
"laxbreak": true
18+
"laxbreak": true,
19+
"multistr": true
2020
}

cli.js

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,6 @@ var opts = nopt({
2121
var args = opts.argv.remain;
2222
var cmd = args[0];
2323

24-
var insight = new Insight({
25-
trackingCode: 'UA-31537568-1',
26-
packageName: pkg.name,
27-
packageVersion: pkg.version
28-
});
29-
30-
if (opts.insight === false) {
31-
insight.config.set('optOut', true);
32-
} else if (opts.insight) {
33-
insight.config.set('optOut', false);
34-
}
35-
36-
/*jshint multistr:true */
37-
var insightMsg = chalk.gray('\
38-
==========================================================================') + chalk.yellow('\n\
39-
We\'re constantly looking for ways to make ') + chalk.bold.red(pkg.name) + chalk.yellow(' better! \n\
40-
May we anonymously report usage statistics to improve the tool over time? \n\
41-
More info: https://github.com/yeoman/insight & http://yeoman.io') + chalk.gray('\n\
42-
==========================================================================');
43-
44-
4524
function rootCheck() {
4625
if (isRoot() && process.setuid) {
4726
try {
@@ -64,6 +43,27 @@ https://gist.github.com/isaacs/579814\n';
6443
sudoBlock(msg);
6544
}
6645

46+
function pre() {
47+
if (opts.version) {
48+
console.log(pkg.version);
49+
return;
50+
}
51+
52+
// debugging helper
53+
if (cmd === 'doctor') {
54+
require('yeoman-doctor').run();
55+
return;
56+
}
57+
58+
// easteregg
59+
if (cmd === 'yeoman' || cmd === 'yo') {
60+
console.log(require('yeoman-character'));
61+
return;
62+
}
63+
64+
init();
65+
}
66+
6767
function init() {
6868
var env = require('yeoman-environment').createEnv();
6969

@@ -111,25 +111,25 @@ function init() {
111111
});
112112
}
113113

114-
function pre() {
115-
if (opts.version) {
116-
console.log(pkg.version);
117-
return;
118-
}
114+
rootCheck();
119115

120-
// debugging helper
121-
if (cmd === 'doctor') {
122-
require('yeoman-doctor').run();
123-
return;
124-
}
116+
var insightMsg = chalk.gray('\
117+
==========================================================================') + chalk.yellow('\n\
118+
We\'re constantly looking for ways to make ') + chalk.bold.red(pkg.name) + chalk.yellow(' better! \n\
119+
May we anonymously report usage statistics to improve the tool over time? \n\
120+
More info: https://github.com/yeoman/insight & http://yeoman.io') + chalk.gray('\n\
121+
==========================================================================');
125122

126-
// easteregg
127-
if (cmd === 'yeoman' || cmd === 'yo') {
128-
console.log(require('yeoman-character'));
129-
return;
130-
}
123+
var insight = new Insight({
124+
trackingCode: 'UA-31537568-1',
125+
packageName: pkg.name,
126+
packageVersion: pkg.version
127+
});
131128

132-
init();
129+
if (opts.insight === false) {
130+
insight.config.set('optOut', true);
131+
} else if (opts.insight) {
132+
insight.config.set('optOut', false);
133133
}
134134

135135
if (!process.env.yeoman_test && opts.insight !== false) {
@@ -158,5 +158,4 @@ if (!process.env.yeoman_test && opts['update-notifier'] !== false) {
158158
}
159159
}
160160

161-
rootCheck();
162161
pre();

0 commit comments

Comments
 (0)