-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtryboot.js
29 lines (28 loc) · 1.03 KB
/
tryboot.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
'use strict'
const { spawn } = require('child_process')
const { RUNTIME, PLATFORM_DIR } = require('./constants')
const pear = require('./cmd')
module.exports = function tryboot () {
const { argv } = global.Bare || global.process
const { flags = {} } = pear(argv.slice(1)) ?? {}
const args = ['--sidecar']
const dhtBootstrap = argv.includes('--dht-bootstrap') ? argv[argv.indexOf('--dht-bootstrap') + 1] : null
if (dhtBootstrap) {
args.push('--dht-bootstrap')
args.push(dhtBootstrap)
}
let detached = true
if (flags.log) {
args.push('--log')
detached = false
} else {
const { length } = args
if (flags.logLevel) args.push('--log-level', flags.logLevel)
if (flags.logFields) args.push('--log-fields', flags.logFields)
if (flags.logLabels) args.push('--log-labels', flags.logLabels)
if (args.length > length) detached = false
}
if (flags.logStacks) args.push('--log-stacks')
const sc = spawn(RUNTIME, args, { detached, stdio: detached ? 'ignore' : 'inherit', cwd: PLATFORM_DIR })
sc.unref()
}