-
Notifications
You must be signed in to change notification settings - Fork 3
/
deploy.js
50 lines (43 loc) · 1013 Bytes
/
deploy.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
var spawn = require('child_process').spawn;
var buildConf = require('./build-config.json');
var THEMES_FOLDER = 'wp-content/themes/';
var themeCount = buildConf.activeThemes.length;
function print(data) {
console.log('' + data);
}
function complete(code) {
console.log('child process exited with code ' + code);
}
function rsync() {
console.log('Starting rsync...');
var r = spawn(
'rsync',
[
'-e',
'ssh',
'-p',
'2222',
'-avz',
'--exclude-from',
'rsync-exclude-list.txt',
'./',
buildConf.remote
]
);
r.stdout.pipe(process.stdout);
r.stderr.pipe(process.stdout);
r.on('close', complete);
}
function prod(theme) {
var p = spawn('npm', ['run', 'prod'], { cwd: 'wp-content/themes/' + theme });
p.stdout.pipe(process.stdout);
p.stderr.pipe(process.stdout);
p.on('close', function(code) {
complete(code);
themeCount--;
if (themeCount === 0) {
rsync();
}
});
}
buildConf.activeThemes.forEach(prod);