forked from AmericanEagle/Mozu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.js
51 lines (51 loc) · 1.64 KB
/
configure.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
var childProcess = require('child_process'),
windows = /^win/.test(process.platform);
(function(cmds, done) {
return cmds.reduceRight(function(cb, command) {
return function() {
console.log('\n>> ' + command.msg + "...");
// the below platform sniff courtesy of https://github.com/joyent/node/issues/2318
if (windows) command.cmd = 'cmd /c ' + command.cmd;
var cmd = command.cmd.split(' ');
var p = childProcess.spawn(cmd[0], cmd.slice(1), { stdio: 'inherit' });
p.on('close', function(code) {
if (code !== 0) {
if (command.err) {
if (command.err(code) === true) {
cb();
}
} else {
console.error('\n>> Command `' + cmd.join(' ') + '` exited with code ' + code + '. Aborting rest of configure.');
}
} else {
cb();
}
});
}
}, done);
})([
{
msg: 'Installing global Grunt',
cmd: 'npm install -g grunt-cli',
err: function(code) {
if (!windows) {
console.error('\n>> Installing global Grunt failed. Your directory permissions may be wrong. Try running this: \n\n\ sudo chown `whoami` `npm prefix -g` && sudo chown `whoami` `npm get cache`');
}
}
},
{
msg: 'Installing global Bower',
cmd: 'npm install -g bower'
},
{
msg: 'Installing local npm dependencies',
cmd: 'npm install'
},
{
msg: 'Running grunt updatereferences task to install core theme references',
cmd: 'grunt updatereferences'
}
], function() {
console.log('\n>> Done! Your system and this directory are now set up to work with Mozu themes.\n');
process.exit(0);
})();