forked from desktop/desktop
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpost-install.ts
63 lines (47 loc) · 1.25 KB
/
post-install.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
#!/usr/bin/env ts-node
import * as Path from 'path'
import { spawnSync, SpawnSyncOptions } from 'child_process'
import * as glob from 'glob'
const root = Path.dirname(__dirname)
const options: SpawnSyncOptions = {
cwd: root,
stdio: 'inherit',
}
function findYarnVersion(callback: (path: string) => void) {
glob('vendor/yarn-*.js', (error, files) => {
if (error != null) {
throw error
}
// this ensures the paths returned by glob are sorted alphabetically
files.sort()
// use the latest version here if multiple are found
const latestVersion = files[files.length - 1]
callback(latestVersion)
})
}
findYarnVersion(path => {
let result = spawnSync(
'node',
[path, '--cwd', 'app', 'install', '--force'],
options
)
if (result.status !== 0) {
process.exit(result.status)
}
result = spawnSync(
'git',
['submodule', 'update', '--recursive', '--init'],
options
)
if (result.status !== 0) {
process.exit(result.status)
}
result = spawnSync('node', [path, 'compile:tslint'], options)
if (result.status !== 0) {
process.exit(result.status)
}
result = spawnSync('node', [path, 'compile:script'], options)
if (result.status !== 0) {
process.exit(result.status)
}
})