-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.js
36 lines (30 loc) · 1005 Bytes
/
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
var version = "0.10.2"
var request = require('request');
var unzip = require('unzip');
var fs = require('fs');
var path = require('path');
var getScriptCs = function() {
var response = request("http://chocolatey.org/api/v2/package/ScriptCs/" + version);
response.pipe(unzip.Extract({path:"scs"}))
.on("close", function(){
copyDir(path.join("scs","tools","scriptcs"), "lib");
});
}
var copyDir = function(src, dest) {
var files = fs.readdirSync(src);
for(var i = 0; i < files.length; i++) {
var current = fs.lstatSync(path.join(src, files[i]));
if(current.isDirectory()) {
copyDir(path.join(src, files[i]), path.join(dest, files[i]));
} else if(current.isSymbolicLink()) {
var symlink = fs.readlinkSync(path.join(src, files[i]));
fs.symlinkSync(symlink, path.join(dest, files[i]));
} else {
copy(path.join(src, files[i]), path.join(dest, files[i]));
}
}
};
var copy = function(src, dest) {
fs.createReadStream(src).pipe(fs.createWriteStream(dest));
};
getScriptCs();