Commit b52bcd9
Changed files (2)
src
test
src/core.ts
@@ -69,6 +69,7 @@ export interface Options {
postfix: string
quote: typeof quote
quiet: boolean
+ detached: boolean
spawn: typeof spawn
spawnSync: typeof spawnSync
log: typeof log
@@ -102,12 +103,12 @@ export const defaults: Options = {
prefix: '',
postfix: '',
quote: noquote,
+ detached: false,
spawn,
spawnSync,
log,
kill,
}
-const isWin = process.platform == 'win32'
export function usePowerShell() {
$.shell = which.sync('powershell.exe')
@@ -256,7 +257,7 @@ export class ProcessPromise extends Promise<ProcessOutput> {
spawnSync: $.spawnSync,
stdio: self._stdio ?? $.stdio,
sync: $[syncExec],
- detached: !isWin,
+ detached: $.detached,
run: (cb) => cb(),
on: {
start: () => {
test/core.test.js
@@ -318,7 +318,7 @@ describe('core', () => {
})
test('abort() method works', async () => {
- const p = $`sleep 9999`
+ const p = $({ detached: true })`sleep 999`
setTimeout(() => p.abort(), 100)
try {
@@ -331,7 +331,7 @@ describe('core', () => {
test('accepts optional AbortController', async () => {
const ac = new AbortController()
- const p = $({ ac })`sleep 9999`
+ const p = $({ ac, detached: true })`sleep 999`
setTimeout(() => ac.abort(), 100)
try {
@@ -345,7 +345,7 @@ describe('core', () => {
test('accepts AbortController `signal` separately', async () => {
const ac = new AbortController()
const signal = ac.signal
- const p = $({ signal })`sleep 9999`
+ const p = $({ signal, detached: true })`sleep 999`
setTimeout(() => ac.abort(), 100)
try {
@@ -357,7 +357,7 @@ describe('core', () => {
})
test('kill() method works', async () => {
- let p = $`sleep 9999`.nothrow()
+ let p = $`sleep 999`.nothrow()
setTimeout(() => {
p.kill()
}, 100)
@@ -471,7 +471,7 @@ describe('core', () => {
test('timeout() works', async () => {
let exitCode, signal
try {
- await $`sleep 9999`.timeout(10, 'SIGKILL')
+ await $`sleep 999`.timeout(10, 'SIGKILL')
} catch (p) {
exitCode = p.exitCode
signal = p.signal