This repository has been archived by the owner on Oct 14, 2018. It is now read-only.
forked from xdevelsistemas/taiga-front-dist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.js
68 lines (60 loc) · 1.96 KB
/
dist.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
var Promise = require("bluebird");
var fs = require("fs");
var delAsync = Promise.promisify(require("del"));
var exec = Promise.promisify(require('child_process').exec);
var ncp = Promise.promisify(require('ncp').ncp);
var local = 'tmp';
var repo = 'https://github.com/taigaio/taiga-front';
if (process.argv.length !== 3){
console.log("¡Error!, call me with somethink like: \nnode dist.js branch_name");
process.exit();
}
var branch = process.argv[2];
var synchRepoAction = (function cloneOrPull(){
var cloned = fs.existsSync(local);
if (cloned) {
action = 'git checkout ' + branch + '&& cd ' + local + ' && git checkout ' + branch + ' && git pull';
} else {
action = 'git checkout ' + branch + '&& git clone -b ' + branch + ' ' + repo + ' ' + local;
}
return action;
}())
exec(synchRepoAction)
.then(function() {
console.log("remove old tmp dist")
//remove old tmp dist
return delAsync(local + '/dist');
})
.then(function() {
console.log("compile taiga")
//compile taiga
return exec('cd ' + local + ' && npm install && bower install && gulp deploy');
})
.then(function() {
console.log("remove old dist")
//remove old dist
return delAsync('dist');
})
.then(function() {
console.log("copy new dist")
//copy new dist
//return ncp(local + '/dist/', 'dist');
return exec('cp -r ' + local + '/dist/ dist');
})
.then(function() {
console.log("get last commit id")
//get last commit id
return exec('cd ' + local + ' && git rev-parse HEAD');
})
.then(function(lastCommitId) {
console.log("commit")
//commit
lastCommitId = lastCommitId[0].trim();
return exec('git add -A && git commit -am "' + lastCommitId + '"');
})
.then(function() {
console.log("push")
//push
return exec('git push origin ' + branch);
})
.done();