From 66338d2b63ff1abdb16c3a8f3c9f35a6b5ed46a7 Mon Sep 17 00:00:00 2001 From: Al Marks Date: Thu, 22 Aug 2024 14:48:14 -0700 Subject: [PATCH] Support node --run (#1169) Adds support for the new node --run feature which is available starting in Node 22 (basically npm run but faster, see https://nodejs.org/en/blog/announcements/v22-release-announce#running-packagejson-scripts and https://www.yagiz.co/developing-fast-builtin-task-runner/). Note that node --run is stricter than the other runners when it comes to distinguishing between arguments for the runner vs the script, so an additional -- is needed to set wireit flags and script flags (explained in the README). Thank you very much to @anonrig for adding the environment variables this required (nodejs/node#53032, nodejs/node#53058) and @justinfagnani for filing the issue (nodejs/node#52673)! There is a problem with recursive invocations on Windows that I believe is a Node bug but need to double-check, tracking at #1168. Fixes #1094 --- .github/workflows/tests.yml | 19 +- CHANGELOG.md | 7 + README.md | 35 +++- src/analyzer.ts | 23 +-- src/cli-options.ts | 29 +-- src/test/basic.test.ts | 60 +++++- src/test/cli-options.test.ts | 362 ++++++++++++++++++++--------------- 7 files changed, 340 insertions(+), 195 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 79c02e2f1..f7e983d9b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -6,26 +6,33 @@ jobs: tests: strategy: # We support Node Current, LTS, and Maintenance. See - # https://nodejs.org/en/about/releases/ for release schedule. + # https://github.com/nodejs/release#release-schedule for release schedule # # We test all supported Node versions on Linux, and the oldest and newest - # on macOS/Windows. + # on macOS/Windows. See + # https://github.com/actions/runner-images?tab=readme-ov-file#available-images + # for the latest available images. matrix: include: + # Maintenance - node: 18 os: ubuntu-22.04 - node: 18 os: macos-13 - node: 18 os: windows-2022 + + # LTS - node: 20 os: ubuntu-22.04 - - node: 20 + + # Current + - node: 22 + os: ubuntu-22.04 + - node: 22 os: macos-13 - - node: 20 + - node: 22 os: windows-2022 - - node: 21 - os: ubuntu-22.04 # Allow all matrix configurations to complete, instead of cancelling as # soon as one fails. Useful because we often have different kinds of diff --git a/CHANGELOG.md b/CHANGELOG.md index e0903da50..9d4621d79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Added + +- Added support for `node --run`, available in Node 22 and above (see + https://nodejs.org/en/blog/announcements/v22-release-announce#running-packagejson-scripts). + ## [0.14.7] - 2024-08-05 - When GitHub caching fails to initialize, more information is now shown about diff --git a/README.md b/README.md index 6eea67cc9..ff4489927 100644 --- a/README.md +++ b/README.md @@ -104,9 +104,7 @@ and replace the original script with the `wireit` command. Now when you run `npm run build`, Wireit upgrades the script to be smarter and -more efficient. Wireit works with [yarn](https://yarnpkg.com/) -(both 1.X "[Classic](https://classic.yarnpkg.com/)" and its successor "Berry") -and [pnpm](https://pnpm.io/), too. +more efficient. Wireit also works with [`node --run`](https://nodejs.org/en/blog/announcements/v22-release-announce#running-packagejson-scripts), [yarn](https://yarnpkg.com/), and [pnpm](https://pnpm.io/). You should also add `.wireit` to your `.gitignore` file. Wireit uses the `.wireit` directory to store caches and other data for your scripts. @@ -238,6 +236,19 @@ npm or Wireit: npm run build -- --verbose ``` +Or in general: + +```sh +npm run {script} {npm args} {wireit args} -- {script args} +``` + +An additional `--` is required when using `node --run` in order to distinguish +between arguments intended for `node`, `wireit`, and the script itself: + +```sh +node --run {script} {node args} -- {wireit args} -- {script args} +``` + ## Input and output files The `files` and `output` properties of `wireit.