-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ts
79 lines (63 loc) · 2.16 KB
/
build.ts
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
import 'https://kwx.kodhe.com/x/v/0.7.3/std/dist/stdlib'
import Child, { ChildProcess } from 'child_process'
import Os from 'os'
import * as async from '/virtual/@kawix/std/util/async'
import Path from 'path'
import fs from '/virtual/@kawix/std/fs/mod'
import Exception from '/virtual/@kawix/std/util/exception'
main()
async function main(){
// build the project
let def = new async.Deferred<void>()
let p: ChildProcess
let exe = "dotnet", dotnetversion
if (Os.platform() == "win32") {
let pathvar = process.env.PATH.split(";")
for (let path of pathvar) {
exe = Path.join(path, "dotnet.exe")
if (fs.existsSync(exe)) break
exe = ''
}
}
if (!exe) throw Exception.create("Dotnet cannot be found").putCode("MISSING_NETCORE")
p = Child.spawn(exe, ["build"], {
cwd: Path.join(__dirname, "src", "netcore", "NetRPA")
})
if(Os.platform() == "win32") p.stdout.setEncoding('latin1')
p.stdout.on("data", function (d) {
process.stdout.write(d)
})
if(Os.platform() == "win32") p.stderr.setEncoding('latin1')
p.stderr.on("data", function (d) {
process.stderr.write(d)
})
p.on("error", def.reject)
p.on("exit", def.resolve)
await def.promise
// Ahora copiar los archivos
let out = Path.join(__dirname, "bin", "netcore")
if(!fs.existsSync(out))
await fs.mkdirAsync(out)
let netcore = Path.join(__dirname, "src", "netcore", "NetRPA", "bin", "Debug")
let filesx = await fs.readdirAsync(netcore)
for (let i = 0; i < filesx.length; i++) {
let file0 = filesx[i]
if (file0.startsWith("netcoreapp")) {
netcore = Path.join(netcore, file0)
break
}
}
// COPY FILES ...
let files = [
"Microsoft.CodeAnalysis.CSharp.dll",
"Microsoft.CodeAnalysis.dll",
"Microsoft.CodeAnalysis.VisualBasic.dll",
"NetRPA.deps.json",
"NetRPA.dll",
"NetRPA.runtimeconfig.json",
"Newtonsoft.Json.dll"
]
for(let tocopy of files){
await fs.copyFileAsync(Path.join(netcore, tocopy), Path.join(out, tocopy))
}
}