-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.js
62 lines (48 loc) · 1.44 KB
/
build.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
/* eslint no-console: 0 */
require('dotenv').config();
// Assume production if not set
if (!process.env.NODE_ENV) {
process.env.NODE_ENV = 'production';
}
// Set Debugging up
if (!process.env.DEBUG) {
process.env.DEBUG = '*:info,*:warn,*:error,*:time';
}
// Debugging
const { debug, info, error } = require('./modules/debugger')('nuxeo-build');
debug('DEBUG', process.env.DEBUG);
info('NODE_ENV', process.env.NODE_ENV);
// npm packages
const Promise = require('bluebird');
const co = require('co');
const fs = require('fs');
const path = require('path');
// Promisified
const readFile = Promise.promisify(fs.readFile);
// local packages
const builder = require('./lib/builder');
const repo_id = process.argv[2];
const repo_path = path.join(__dirname, 'repositories', repo_id);
const branch = process.argv[3];
const source_path = process.argv[4].replace(/(^"|"$)/g, '');
const target_path = process.argv[5].replace(/(^"|"$)/g, '');
debug({ repo_id, branch, source_path, target_path });
co(function* () {
console.time('Build');
info('Starting Build: %s - %s', repo_id, branch);
// Get the metadata
const metadata_raw = yield readFile(
path.join(__dirname, 'temp/metadata.json')
);
const metadata = JSON.parse(metadata_raw);
debug(Object.keys(metadata));
yield builder(source_path, metadata, target_path, {
repo_id,
repo_path,
branch,
});
console.timeEnd('Build');
}).catch(function (err) {
error(err);
throw err;
});