forked from agracio/edge-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.js
82 lines (67 loc) · 1.94 KB
/
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
var fs = require('fs')
, path = require('path')
, spawn = require('child_process').spawn
, whereis = require('./whereis');
if (process.platform === 'win32') {
var libroot = path.resolve(__dirname, '../lib/native/win32')
, lib32bit = path.resolve(libroot, 'ia32')
, lib64bit = path.resolve(libroot, 'x64');
function copyFile(filePath, filename) {
return function(copyToDir) {
fs.writeFileSync(path.resolve(copyToDir, filename), fs.readFileSync(filePath));
};
}
function isDirectory(info) {
return info.isDirectory;
}
function getInfo(basedir) {
return function(file) {
var filepath = path.resolve(basedir, file);
return {
path: filepath,
isDirectory: fs.statSync(filepath).isDirectory()
};
}
}
function getPath(info) {
return info.path;
}
var dest32dirs = fs.readdirSync(lib32bit)
.map(getInfo(lib32bit))
.filter(isDirectory)
.map(getPath);
var redist = [
'concrt140.dll',
'msvcp140.dll',
'vccorlib140.dll',
'vcruntime140.dll',
];
redist.forEach(function (dllname) {
var dll32bit = path.resolve(lib32bit, dllname);
dest32dirs.forEach(copyFile(dll32bit, dllname));
});
var dest64dirs = fs.readdirSync(lib64bit)
.map(getInfo(lib64bit))
.filter(isDirectory)
.map(getPath);
redist.forEach(function (dllname) {
var dll64bit = path.resolve(lib64bit, dllname);
dest64dirs.forEach(copyFile(dll64bit, dllname));
});
var dotnetPath = whereis('dotnet', 'dotnet.exe');
if (dotnetPath) {
spawn(dotnetPath, ['restore'], { stdio: 'inherit', cwd: path.resolve(__dirname, '..', 'lib', 'bootstrap') })
.on('close', function() {
spawn(dotnetPath, ['build', '--configuration', 'Release'], { stdio: 'inherit', cwd: path.resolve(__dirname, '..', 'lib', 'bootstrap') })
.on('close', function() {
require('./checkplatform');
});
});
}
else {
require('./checkplatform');
}
}
else {
spawn('node-gyp', ['configure', 'build'], { stdio: 'inherit' });
}