-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathinstall.js
More file actions
38 lines (32 loc) · 1012 Bytes
/
install.js
File metadata and controls
38 lines (32 loc) · 1012 Bytes
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
var fs = require("fs");
var path = require('path');
var parentPath = path.dirname(__filename);
var nativeModule = parentPath + "/binary/" + process.platform + "_" + process.arch + "/";
var devMode = true;
var isNative = false;
if (!fs.existsSync("Makefile")) {
devMode = false;
}
if (fs.existsSync(nativeModule) && !devMode) {
try {
var PL = require(nativeModule +'phplike' );
var res = PL.exec("echo a");
if (res.match(/^a/)) {
isNative = true;
}
} catch (e) {
//console.log(e);
console.log("Binary code could not be loaded.");
}
}
if (isNative == false) {
var fileHandle = require('./src/js/file.js');
var isForce = true;
if (!devMode) fileHandle.rmdir('./binary', isForce);
console.log("Auto Recompile C/C++ library.");
var proce = require('child_process');
var res = proce.exec('node-gyp rebuild', function (error, stdout, stderr) {
console.log(stdout);
console.log(stderr);
});
}