Commit fe1646a
Changed files (15)
.github
_workflows
workflows
test
fixtures
.github/_workflows/check.yml
@@ -1,43 +0,0 @@
-name: Check
-
-on: [push, pull_request]
-
-jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - run: npm i
- - run: npm run build:check
-
- coverage:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - run: npm i
- - run: npm run coverage
- timeout-minutes: 1
- env:
- FORCE_COLOR: 3
-
- code-style:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - run: npm i
- - run: npm run fmt:check
-
- types:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - run: npm i
- - run: npm run build
- - run: npm run test:types
-
- circular:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - run: npm i
- - run: npm run circular
.github/_workflows/dev-publish.yml
@@ -1,23 +0,0 @@
-name: Dev Publish
-
-on:
- push:
- branches:
- - dev
-
-jobs:
- publish:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-node@v3
- with:
- node-version: 18
- - run: npm i
- - run: npm test
- - run: echo "//wombat-dressing-room.appspot.com/:_authToken=$AUTH_TOKEN" >> .npmrc
- env:
- AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
- - run: |
- npm version $(node --eval="process.stdout.write(require('./package.json').version)")-dev.$(git rev-parse --short HEAD) --no-git-tag-version
- npm publish --no-git-tag-version --tag dev
.github/_workflows/npm-publish.yml
@@ -1,20 +0,0 @@
-name: Publish
-
-on:
- release:
- types: [created]
-
-jobs:
- publish:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-node@v3
- with:
- node-version: 16
- - run: npm i
- - run: npm test
- - run: echo "//wombat-dressing-room.appspot.com/:_authToken=$AUTH_TOKEN" >> .npmrc
- env:
- AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
- - run: npm publish
.github/_workflows/test.yml
@@ -1,39 +0,0 @@
-name: Test
-
-on: [push, pull_request]
-
-jobs:
- test:
- runs-on: ubuntu-latest
-
- strategy:
- matrix:
- node-version: [16.x, 18.x]
-
- steps:
- - uses: actions/checkout@v3
- - name: Use Node.js ${{ matrix.node-version }}
- uses: actions/setup-node@v3
- with:
- node-version: ${{ matrix.node-version }}
- - run: npm i
- - run: npm test
- timeout-minutes: 1
- env:
- FORCE_COLOR: 3
-
- win32:
- runs-on: windows-latest
-
- steps:
- - uses: actions/checkout@v3
- - name: Use Node.js 16.x
- uses: actions/setup-node@v3
- with:
- node-version: 16.x
- - run: npm i
- - run: npm run build
- - run: npx uvu test win32
- timeout-minutes: 1
- env:
- FORCE_COLOR: 3
.github/workflows/v7-publish.yml
@@ -0,0 +1,32 @@
+name: zx@7 Publish
+
+on:
+ workflow_dispatch:
+ release:
+ types: [created]
+
+jobs:
+ publish:
+ if: github.ref == 'refs/heads/v7'
+ runs-on: ubuntu-latest
+ permissions:
+ checks: read
+ statuses: write
+ contents: write
+ packages: write
+ id-token: write
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 18
+ - run: npm ci
+ - run: npm run build
+ - run: npm run test:unit
+ env:
+ FORCE_COLOR: 3
+
+ - run: echo "//wombat-dressing-room.appspot.com/:_authToken=$AUTH_TOKEN" >> .npmrc
+ env:
+ AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
+ - run: npm publish --provenance --access=public --no-git-tag-version --tag v7
.github/workflows/v7-test.yml
@@ -0,0 +1,117 @@
+name: zx@7 Test
+
+on:
+ push:
+ pull_request:
+ schedule:
+ - cron: '0 12 */4 * *'
+
+permissions:
+ contents: read
+
+env:
+ FORCE_COLOR: 3
+ NODE_OPTIONS: '--http-parser=legacy'
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+
+ - name: Use Node.js 18.x
+ uses: actions/setup-node@v4
+ with:
+ node-version: 18.x
+ cache: 'npm'
+
+ - run: npm ci
+ - run: |
+ npm run build
+ cd build && ls -l
+ - uses: actions/upload-artifact@v4
+ with:
+ name: v7
+ path: |
+ build
+ package.json
+ retention-days: 1
+
+ fast-check:
+ needs: build
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+
+ - uses: actions/download-artifact@v4
+ with:
+ name: v7
+ - run: npm ci
+
+ - name: Code-style
+ run: npm run fmt:check
+
+ - name: Types
+ run: npm run test:types
+
+ - name: Circular
+ run: npm run test:circular
+
+ unit:
+ needs: build
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ node-version: [16, 18, 24]
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+
+ - uses: actions/download-artifact@v4
+ with:
+ name: v7
+
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v4
+ with:
+ node-version: ${{ matrix.node-version }}
+ cache: 'npm'
+
+ - run: npm ci
+
+ - name: Run units with coverage
+ if: matrix.node-version == '18'
+ run: npm run test:coverage
+ timeout-minutes: 1
+
+ - name: Run units
+ if: matrix.node-version != '18'
+ run: npm run test:unit
+ timeout-minutes: 1
+
+ win32:
+ needs: build
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+
+ - uses: actions/download-artifact@v4
+ with:
+ name: v7
+
+ - name: Use Node.js 16.x
+ uses: actions/setup-node@v4
+ with:
+ node-version: 16.x
+
+ - run: npm ci
+
+ - run: npx uvu test win32
+ timeout-minutes: 1
src/core.ts
@@ -425,10 +425,10 @@ export class ProcessOutput extends Error {
stderr: ${stringify(this.stderr, chalk.red)},
signal: ${inspect(this.signal)},
exitCode: ${(this.exitCode === 0 ? chalk.green : chalk.red)(this.exitCode)}${
- exitCodeInfo(this.exitCode)
- ? chalk.grey(' (' + exitCodeInfo(this.exitCode) + ')')
- : ''
- }
+ exitCodeInfo(this.exitCode)
+ ? chalk.grey(' (' + exitCodeInfo(this.exitCode) + ')')
+ : ''
+ }
}`
}
}
src/goods.ts
@@ -40,8 +40,7 @@ export const globby = Object.assign(function globby(
options?: globbyModule.Options
) {
return globbyModule.globby(patterns, options)
-},
-globbyModule)
+}, globbyModule)
export const glob = globby
export function sleep(duration: Duration) {
test/fixtures/500.http
@@ -0,0 +1,6 @@
+HTTP/1.1 500 Internal Server Error
+Content-Type: text/plain; charset=UTF-8
+Content-Length: 5
+Server: netcat!
+
+Error
test/fixtures/echo.http
@@ -2,5 +2,5 @@ HTTP/1.1 200 OK
Content-Type: text/javascript; charset=UTF-8
Content-Length: 15
Server: netcat!
-
-$`echo 'test'`
+
+$`echo 'test'`
test/fixtures/no-extension
@@ -1,13 +1,13 @@
#!/usr/bin/env zx
// Copyright 2021 Google LLC
-//
+//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
-//
+//
// https://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
test/cli.test.js
@@ -114,8 +114,7 @@ test('scripts from https', async () => {
const resp = await fs.readFile(path.resolve('test/fixtures/echo.http'))
const port = await getPort()
const server = await getServer([resp]).start(port)
- const out =
- await $`node build/cli.js http://127.0.0.1:${port}/script.mjs`
+ const out = await $`node build/cli.js http://127.0.0.1:${port}/script.mjs`
assert.match(out.toString(), /test/)
await server.stop()
@@ -123,8 +122,10 @@ test('scripts from https', async () => {
test('scripts from https not ok', async () => {
const port = await getPort()
- const server = await getServer(['HTTP/1.1 500\n\n']).listen(port)
+ const resp = await fs.readFile(path.resolve('test/fixtures/500.http'))
+ const server = await getServer([resp]).start(port)
const out = await $`node build/cli.js http://127.0.0.1:${port}`.nothrow()
+
assert.match(out.stderr, /Error: Can't get/)
await server.stop()
})
@@ -212,7 +213,9 @@ test('argv works with zx and node', async () => {
`global {"_":["bar"]}\nimported {"_":["bar"]}\n`
)
assert.match(
- (await $`node build/cli.js --eval 'console.log(argv._)' foobarbaz`).toString(),
+ (
+ await $`node build/cli.js --eval 'console.log(argv._)' foobarbaz`
+ ).toString(),
/foobarbaz/
)
})
package-lock.json
@@ -1,12 +1,12 @@
{
"name": "zx",
- "version": "7.2.3",
+ "version": "7.2.4",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "zx",
- "version": "7.2.3",
+ "version": "7.2.4",
"license": "Apache-2.0",
"dependencies": {
"@types/fs-extra": "^11.0.4",
package.json
@@ -1,6 +1,6 @@
{
"name": "zx",
- "version": "7.2.3",
+ "version": "7.2.4",
"description": "A tool for writing better scripts",
"type": "module",
"main": "./build/index.js",
@@ -46,9 +46,9 @@
"test": "npm run build && npm run test:unit",
"test:unit": "uvu test -i fixtures",
"test:types": "tsd",
- "coverage": "c8 --check-coverage npm test -- -i package",
- "mutation": "stryker run",
- "circular": "madge --circular src/*",
+ "test:coverage": "c8 --check-coverage npm run test:unit -- -i package",
+ "test:mutation": "stryker run",
+ "test:circular": "madge --circular src/*",
"version": "cat package.json | fx .version"
},
"dependencies": {
@@ -88,7 +88,8 @@
"prettier": {
"semi": false,
"singleQuote": true,
- "endOfLine": "lf"
+ "endOfLine": "lf",
+ "trailingComma": "es5"
},
"repository": "google/zx",
"author": "Anton Medvedev <anton@medv.io>",
README.md
@@ -1,8 +1,8 @@
# ๐ zx
> [!TIP]
-> **zx@7** is no longer actively maintained. Critical bug fixes and vulnerability fixes only considered.
->
+> **zx@7** is no longer actively maintained. Critical bug fixes and vulnerability fixes only considered.
+>
> Check this out: [**zx@8**](https://github.com/google/zx/releases/tag/8.0.0) is a giant leap forward. [There are a lot](https://github.com/google/zx/releases) of cool features, improvements, compatibility enhancements ๐
> Please follow the [migration guide](https://google.github.io/zx/migration-from-v7) to upgrade to the latest. If something doesn't work, feel free to start a new [issue](https://github.com/google/zx/issues) or [discussion](https://github.com/google/zx/discussions).