@@ -21,27 +21,6 @@ var opts = nopt({
2121var args = opts . argv . remain ;
2222var 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-
4524function 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+
6767function 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
135135if ( ! 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 ( ) ;
162161pre ( ) ;
0 commit comments