File tree Expand file tree Collapse file tree 2 files changed +36
-6
lines changed Expand file tree Collapse file tree 2 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -20,19 +20,34 @@ exports.setOptions = function (optimist) {};
20
20
exports . npmInstall = function ( ) {
21
21
var currentNpm = null ;
22
22
23
+ // 检测是否存在 ykit.*.js
24
+ var configFile = globby . sync ( [ 'ykit.*.js' , 'ykit.js' ] , { cwd : process . cwd ( ) } ) [ 0 ] ;
25
+ if ( ! configFile ) {
26
+ log ( '未发现存在 ykit 配置文件,编译退出.' ) ;
27
+ process . exit ( 1 ) ;
28
+ }
29
+
30
+ // 检测是否存在 node_modules
31
+ var isNodeModulesExists = fs . existsSync ( sysPath . join ( process . cwd ( ) , 'node_modules' ) ) ;
32
+ if ( isNodeModulesExists ) {
33
+ log ( '发现仓库中已存在 node_modules,这会导致由于 npm 包系统版本不兼容而编译失败,请从仓库中删除并重新编译.' ) ;
34
+ process . exit ( 1 ) ;
35
+ }
36
+
23
37
try {
24
38
child_process . execSync ( 'npm_cache_share -h' ) ;
25
39
26
40
if ( UtilFs . fileExists ( sysPath . join ( process . cwd ( ) , 'npm-shrinkwrap.json' ) ) ) {
27
41
currentNpm = 'npm_cache_share' ;
28
- log ( '将使用 npm_cache_share 进行模块安装' ) ;
42
+ log ( '将使用 npm_cache_share 进行模块安装. ' ) ;
29
43
} else {
30
44
currentNpm = 'npm' ;
31
- log ( 'npm-shrinkwrap.json 不存在,将使用 npm 进行模块安装' ) ;
45
+ log ( 'npm-shrinkwrap.json 不存在,将使用 npm 进行模块安装.' ) ;
46
+ log ( '建议使用 shrinkwrap 固定模块版本,否则构建存在风险。文档请参考:http://ued.qunar.com/ykit/docs-npm%20shrinkwrap.html' ) ;
32
47
}
33
48
} catch ( e ) {
34
49
currentNpm = 'npm' ;
35
- log ( 'npm_cache_share 不存在,将使用 npm 进行模块安装' ) ;
50
+ log ( 'npm_cache_share 不存在,将使用 npm 进行模块安装. ' ) ;
36
51
}
37
52
38
53
// cache clean
Original file line number Diff line number Diff line change @@ -22,19 +22,34 @@ exports.setOptions = (optimist) => {
22
22
exports . npmInstall = function ( ) {
23
23
let currentNpm = null ;
24
24
25
+ // 检测是否存在 ykit.*.js
26
+ const configFile = globby . sync ( [ 'ykit.*.js' , 'ykit.js' ] , { cwd : process . cwd ( ) } ) [ 0 ] ;
27
+ if ( ! configFile ) {
28
+ log ( '未发现存在 ykit 配置文件,编译退出.' ) ;
29
+ process . exit ( 1 ) ;
30
+ }
31
+
32
+ // 检测是否存在 node_modules
33
+ const isNodeModulesExists = fs . existsSync ( sysPath . join ( process . cwd ( ) , 'node_modules' ) ) ;
34
+ if ( isNodeModulesExists ) {
35
+ log ( '发现仓库中已存在 node_modules,这会导致由于 npm 包系统版本不兼容而编译失败,请从仓库中删除并重新编译.' ) ;
36
+ process . exit ( 1 ) ;
37
+ }
38
+
25
39
try {
26
40
child_process . execSync ( 'npm_cache_share -h' ) ;
27
41
28
42
if ( UtilFs . fileExists ( sysPath . join ( process . cwd ( ) , 'npm-shrinkwrap.json' ) ) ) {
29
43
currentNpm = 'npm_cache_share' ;
30
- log ( '将使用 npm_cache_share 进行模块安装' ) ;
44
+ log ( '将使用 npm_cache_share 进行模块安装. ' ) ;
31
45
} else {
32
46
currentNpm = 'npm' ;
33
- log ( 'npm-shrinkwrap.json 不存在,将使用 npm 进行模块安装' ) ;
47
+ log ( 'npm-shrinkwrap.json 不存在,将使用 npm 进行模块安装.' ) ;
48
+ log ( '建议使用 shrinkwrap 固定模块版本,否则构建存在风险。文档请参考:http://ued.qunar.com/ykit/docs-npm%20shrinkwrap.html' ) ;
34
49
}
35
50
} catch ( e ) {
36
51
currentNpm = 'npm' ;
37
- log ( 'npm_cache_share 不存在,将使用 npm 进行模块安装' ) ;
52
+ log ( 'npm_cache_share 不存在,将使用 npm 进行模块安装. ' ) ;
38
53
}
39
54
40
55
// cache clean
You can’t perform that action at this time.
0 commit comments