github
295 of 338 branches covered (87.28%)
Branch coverage included in aggregate %.
234 of 272 new or added lines in 22 files covered. (86.03%)
1346 of 1485 relevant lines covered (90.64%)
210.26 hits per line
|
import child_process from 'node:child_process' |
|
|
import fs from 'node:fs/promises' |
1✔ |
|
|
1✔ |
|
const fileExists = path => fs.access(path).then(() => !!1).catch(() => !!0) |
|
|
|
1✔ |
|
const onStdout = (cmd, { cwd }) => { |
1✔ |
NEW
|
const ctrlr = new AbortController()
|
× |
NEW
|
|
× |
NEW
|
return new Promise((resolve, reject) => { |
× |
NEW
|
const res = child_process.exec(cmd, { cwd, signal: ctrlr.signal })
|
× |
NEW
|
const timer = setTimeout(() => { |
× |
NEW
|
reject(new Error('Did not log in stdout within 1000ms'), 1000) |
× |
NEW
|
ctrlr.abort() |
× |
NEW
|
}) |
× |
NEW
|
|
× |
NEW
|
res.stderr.once('data', data => reject(new Error(data))) |
× |
NEW
|
res.stdout.once('data', data => {
|
× |
NEW
|
clearTimeout(timer) |
× |
NEW
|
resolve(data.toString()) |
× |
NEW
|
ctrlr.abort() |
× |
NEW
|
}) |
× |
NEW
|
}) |
× |
NEW
|
} |
× |
|
|
1✔ |
|
export { fileExists, onStdout }
|
1✔ |