-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
76 lines (71 loc) · 2 KB
/
init.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var fileArray=[
"src/assets/font",
"src/assets/img",
"src/assets/css",
"src/assets/vendor",
"src/assets/cursor",
"src/assets/icon",
"src/assets/lib/ng",
"src/script",
"src/bower_components",
"src/less",
"src/dev",
"src/dev/lib",
"src/dev/css",
"src/dev/js",
"src/style/phone",
"src/views/template",
"dist",
"doc",
"test",
"test/e2e",
"test/unit"
//,"gulp/node_modules"
];
var glupArray=[
"gulp","del","gulp-concat","gulp-uglify","gulp-jshint","gulp-minify","amd-optimize",
"gulp-imagemin","gulp-copy"
];
var path=require('path'), fs=require('fs');
var exec = require('child_process').exec;
var approotPath=path.join(__dirname,'..');
console.log("approotPath: "+approotPath);
//递归创建目录 同步方法
function mkdirsSync(dirname, mode){
if(fs.existsSync(dirname)){
return true;
}else{
if(mkdirsSync(path.dirname(dirname), mode)){
fs.mkdirSync(dirname, mode);
return true;
}
}
}
function initDir(){
for(var item in fileArray){
console.info(path.join(approotPath,fileArray[item]));
mkdirsSync(path.join(__dirname,fileArray[item]),null,function(){});
}
}
var npmcmd="npm -v";
initDir();
//exec(npmcmd, function(error, stdout, stderr) {
// if(error) console.warn('not install npm')
// else {
// console.log('npm version: ' + stdout);
// exec("cd " + path.join(__dirname,'gulp'), function (error, stdout, stderr) {
// if (!error)
// glupArray.forEach(function (item) {
// var npmcmdItem = "sudo npm install "+item+" --save";
// exec(npmcmdItem, function(error, stdout, stderr) {
// if(!error){
// console.log(npmcmdItem);
// }else{
// console.warn(stdout,stderr);
// }
// });
// });
// else console.warn(stdout,stderr);
// });
// }
//});