-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexecute-order-66.js
59 lines (44 loc) · 1.58 KB
/
execute-order-66.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
'use strict'
const args = process.argv.slice(2)
if (!args.length) throw new Error('pls specify neovim source dir kthx')
const { spawn } = require('child_process')
const path = require('path')
const neovimDir = path.resolve(args[0])
const main = async () => {
const nrun = cmd => run(cmd, { cwd: neovimDir })
const dest = p => path.join(process.cwd(), os, p)
await nrun('rm -rf build')
await nrun('make clean && make CMAKE_BUILD_TYPE=Release')
await nrun(`mkdir -p ${dest('bin')}`)
await nrun(`mkdir -p ${dest('share/runtime')}`)
await nrun(`cp -r build/bin/nvim ${dest('bin/nvim')}`)
await nrun(`cp -r runtime ${dest('share')}`)
await nrun(`cp -r build/runtime/doc ${dest('share/runtime')}`)
await nrun(`cp -r build/runtime/syntax/vim ${dest('share/runtime/syntax')}`)
}
const os = ({
darwin: 'mac',
linux: 'linux',
win32: 'win',
})[process.platform]
const run = (cmd, opts = {}) => new Promise(done => {
console.log(cmd)
const [ command, ...args ] = cmd.split(' ')
const proc = spawn(command, args, { ...opts, shell: true })
const exit = () => (proc.kill(), process.exit())
process.on('SIGBREAK', exit)
process.on('SIGTERM', exit)
process.on('SIGHUP', exit)
process.on('SIGINT', exit)
proc.stdout.pipe(process.stdout)
proc.stderr.pipe(process.stderr)
proc.on('exit', done)
if (opts.outputMatch) proc.stdout.on('data', data => {
const outputHas = data
.toString()
.toLowerCase()
.includes(opts.outputMatch)
if (outputHas && typeof opts.onOutputMatch === 'function') opts.onOutputMatch()
})
})
main().catch(console.error)