-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-install.js
63 lines (54 loc) · 1.72 KB
/
pre-install.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 fs = require('fs')
var process = require('process')
class InstallReactAndNodered {
constructor(uibuilderNodeName) {
this.uibuilderRelativePath = "/uibuilder/" + uibuilderNodeName + "/src/react_webix/"
this.uibuilderDistRelativePath = '/uibuilder/' + uibuilderNodeName + '/dist/'
}
// Getter
installReact() {
let stdout = "ok"
var react = process.cwd() + this.uibuilderRelativePath
console.log('Installing ReactJS in cwd: ' + react);
stdout = require('child_process').execSync('npm install '+ react, {cwd:react})
if(stdout.status){
console.log(stdout.status)
process.exit()
}
stdout = require('child_process').execSync('npm run build', {cwd:react})
if(stdout.status){
console.log(stdout.status)
process.exit()
}
return stdout
}
installNodeRed() {
let err = "ok"
console.log("Creating Symlink in cwd: " + process.cwd())
fs.symlink(process.cwd() + this.uibuilderRelativePath + 'build/', process.cwd() + this.uibuilderDistRelativePath, 'junction', function(err,stdout,stderr){
console.log('err: ' + err)
console.log('stdout: ' + stdout)
console.log('stderr: ' + stderr)
})
// console.log('"Installing NodeRed" cwd: ' + process.cwd());
// var react = process.cwd()+ './'
// stdout = require('child_process').execSync('npm install ', {cwd:react})
// if(stdout.status){
// console.log(stdout)
// process.exit()
// }
}
execute() {
this.installReact()
this.installNodeRed()
}
// Method
calcArea() {
return this.height * this.width;
}
}
const react_ui = new InstallReactAndNodered("react_ui");
react_ui.execute()
// const snw = new InstallReactAndNodered("snw");
// snw.execute()
console.log("Install Done")