Skip to content

Commit

Permalink
test: add bun to test matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
antongolub committed Jun 1, 2024
1 parent 2940799 commit 19dc7b0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,17 @@ jobs:

- name: Run smoke:cjs tests
run: npm run test:smoke:cjs

smoke-bun:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: antongolub/action-setup-bun@v1
- uses: actions/download-artifact@v4
with:
name: build
- run: |
bun ./src/test/smoke/invoke.test.cjs
bun ./src/test/smoke/invoke.test.mjs
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# 🔬🧫

> This subproject is a kind of experiment, addressed to the [google/zx/issues/589](https://github.com/google/zx/issues/589).
Just a testing ground for verifying ideas and approaches aimed at improve the [zx](https://github.com/google/zx) architecture.
Just a testing ground for verifying ideas and approaches aimed at improve the [zx's](https://github.com/google/zx) architecture.

## Concepts
* **Layered** architecture:
Expand All @@ -20,6 +20,16 @@ Just a testing ground for verifying ideas and approaches aimed at improve the [z
* The context object at every layer is accessible fo modify.
* Typings are mostly represented by interfaces, so it's easy to tweak up if necessary.

## Requirements
* **OS**
* Linux
* MacOS
* Windows
* **JS Runtime**
* Node.js >= 6 (CJS)
* Node.js >= 12 (ESM)
* Bun >= 1.0.0

## Install
```bash
yarn add zurk
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 @@ -86,13 +86,14 @@ export interface TShellSync {
}

export const $: TShell = function(this: any, pieces?: any, ...args: any): any {
const preset = this || {}
const self = (this !== globalThis) && this
const preset = self || {}

if (pieces === undefined) return applyMixins($, preset)

if (isStringLiteral(pieces)) return ignite(preset, pieces, ...args)

return (...args: any) => $.apply(this ? assign(this, pieces) : pieces, args)
return (...args: any) => $.apply(self ? assign(self, pieces) : pieces, args)
}

const ignite = (preset: any, pieces: TemplateStringsArray, ...args: any[]) => {
Expand Down
21 changes: 17 additions & 4 deletions src/test/smoke/invoke.test.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import assert from 'assert'
import { zurk } from 'zurk'
import { zurk, $ } from '../../../target/esm/index.mjs'

const result = zurk({ sync: true, cmd: 'echo', args: ['foo'] })
assert.match(result.stdout, /foo/)
assert.equal(result.status, 0)
const keepAlive = setInterval(() => {}, 1000 * 60 * 60)

const r1 = zurk({ sync: true, cmd: 'echo', args: ['foo'] })
assert.ok(/foo/.test(r1.stdout))
assert.equal(r1.status, 0)

const r2 = $({sync: true})`echo bar`
assert.ok(/bar/.test(r2.stdout))
assert.equal(r2.status, 0);

$`echo baz`.then((r3) => {
assert.ok(/baz/.test(r3.stdout))
assert.equal(r3.status, 0)
clearInterval(keepAlive)
})

console.log('nodejs:', process.versions.node)
console.log('smoke mjs: ok')

0 comments on commit 19dc7b0

Please sign in to comment.