-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparse.js
35 lines (30 loc) · 867 Bytes
/
parse.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
var Promise = require("bluebird");
var yaml = require('js-yaml');
var fs = Promise.promisifyAll(require("fs"));
var R = require('ramda');
var homeDir = process.env.HOME;
var prepareShFile = function(json) {
var contents = [
'cd ~/build',
'set -x'
];
contents = contents.concat(json.before_script);
contents = contents.concat(json.script);
return contents.join('\n');
};
fs.readFileAsync(homeDir + '/build/.shoov.yml')
.then(function (data) {
return yaml.safeLoad(data);
})
.then(function (json) {
return fs.writeFileAsync(homeDir + '/shoov.sh', prepareShFile(json));
})
.then(function() {
return fs.chmodAsync(homeDir + '/shoov.sh', '777')
})
.catch(SyntaxError, function (e) {
console.error("file contains invalid json");
})
.catch(Promise.OperationalError, function (e) {
console.error(e.message);
});