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 4525b90 commit ec3addd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
uses: denoland/setup-deno@v2
with:
deno-version: ${{ matrix.deno-version }}
- run: deno install
- run: deno install npm:types/node
- uses: actions/download-artifact@v4
with:
name: build
Expand Down
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
5 changes: 3 additions & 2 deletions src/main/ts/x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
quote,
buildCmd,
parseInput,
g
g,
immediate
} from './util.js'
import { pipeMixin } from './mixin/pipe.js'
import { killMixin } from './mixin/kill.js'
Expand Down Expand Up @@ -102,7 +103,7 @@ const ignite = (preset: any, pieces: TemplateStringsArray, ...args: any[]) => {
const input = parseInput(preset.input)
const run = cmd instanceof Promise
? (cb: TVoidCallback, ctx: TShellCtx) => cmd.then((cmd) => { ctx.cmd = cmd; cb() })
: setImmediate
: immediate
const opts = assign(preset, { cmd, run, input })

return applyMixins($, opts)
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 ec3addd

Please sign in to comment.