Skip to content

Commit

Permalink
feat: provide deno support
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Oct 17, 2024
1 parent 9c33048 commit 3175a6e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/ts/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as cp from 'node:child_process'
import process from 'node:process'
import EventEmitter from 'node:events'
import { Readable, Writable, Stream, Transform } from 'node:stream'
import { assign, noop, randomId, g } from './util.js'
import { assign, noop, randomId, g, immediate } from './util.js'

export * from './util.js'

Expand Down Expand Up @@ -102,7 +102,7 @@ export const defaults: TSpawnCtxNormalized = {
get stdout(){ return new VoidStream() },
get stderr(){ return new VoidStream() },
stdio: ['pipe', 'pipe', 'pipe'],
run: g.setImmediate,
run: immediate
}

export const normalizeCtx = (...ctxs: TSpawnCtx[]): TSpawnCtxNormalized => assign({
Expand Down
2 changes: 2 additions & 0 deletions src/main/ts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Buffer } from 'node:buffer'

export const g = (!process.versions.deno && global) || globalThis

export const immediate = g.setImmediate || ((f: any) => g.setTimeout(f, 0))

export const noop = () => { /* noop */ }

export const randomId = () => Math.random().toString(36).slice(2)
Expand Down
1 change: 1 addition & 0 deletions src/test/smoke/invoke.test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import assert from 'node:assert'
import process from 'node:process'
import { zurk, $ } from '../../../target/esm/index.mjs'

const keepAlive = setInterval(() => {}, 1000 * 60 * 60)
Expand Down

0 comments on commit 3175a6e

Please sign in to comment.