diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 21583fad..be4d662d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -45,7 +45,7 @@ jobs: NO_ELM_TOOLING_INSTALL: 1 - name: elm-tooling install - run: npx --no-install elm-tooling install + run: npm run prepare - name: Flow run: npx --no-install flow check diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf9c394c..27ba0ff5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,7 +45,7 @@ jobs: NO_ELM_TOOLING_INSTALL: 1 - name: elm-tooling install - run: npx --no-install elm-tooling install + run: npm run prepare - name: Mocha run: npx --no-install mocha tests diff --git a/elm-tooling-polyfill.js b/elm-tooling-polyfill.js new file mode 100644 index 00000000..7fd83f42 --- /dev/null +++ b/elm-tooling-polyfill.js @@ -0,0 +1,11 @@ +// Only `elm-tooling/getExecutable` supports Node.js 10, the rest of it is +// Node.js 12+. Luckily, all that’s needed is to polyfill `.flatMap`. +// We can get rid of this when Node.js 10 becomes EOL 2021-04-30 and support for +// Node.js 10 is dropped. +// Note: This is only used during development and CI of node-test-runner, not +// for users of the npm package. +if (Array.prototype.flatMap === undefined) { + Array.prototype.flatMap = function flatMap(...args) { + return [].concat(...this.map(...args)); + }; +} diff --git a/package.json b/package.json index 1ed73bb9..b5e0bd39 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "check": "flow check && npm run lint && npm run format:check && npm run review", "format:check": "prettier --check . && elm-format elm --validate", "format:write": "prettier --write . && elm-format elm --yes", - "prepare": "elm-tooling install" + "prepare": "node -r ./elm-tooling-polyfill.js node_modules/elm-tooling/index.js install" }, "repository": { "type": "git",