forked from Rapid-Application-Development-JS/RAD.JS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
63 lines (48 loc) · 1.47 KB
/
main.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
var exec = require('child_process').exec,
fs = require('fs'),
path = require('path'),
child;
var modes = ['dev', 'release'];
function build(mode, cb){
if (modes.indexOf(mode) < 0){
console.log('Incorrect mode specified');
return false;
}
var structSource = path.join(__dirname, 'structure.json'),
structDest = path.join(__dirname, '/bin/structure.json');
try {
var structure = fs.readFileSync(structSource);
fs.writeFileSync(structDest, structure);
} catch (e) {
console.log(e);
}
child = exec('./node_modules/.bin/grunt ' + mode,
{ cwd : __dirname },
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
var fileName = 'rad.js',
filePath='';
if (error !== null) {
console.log('exec error: ' + error);
} else {
filePath = path.resolve(path.join(__dirname, 'bin', fileName));
}
if (typeof cb == 'function'){
cb(filePath);
}
});
}
function getLibsPath(){
return path.join(__dirname, 'examples', 'libs');
}
function getCssPath(){
return path.join(__dirname, 'css');
}
function getRADPath(){
return path.join(__dirname, 'bin', 'rad.js');
}
exports.build = build;
exports.getLibsPath = getLibsPath;
exports.getCssPath = getCssPath;
exports.getRADPath = getRADPath;