Skip to content

Commit

Permalink
Fix: npm prepare script on Windows (refs #166) (#168)
Browse files Browse the repository at this point in the history
* Chore: Test on Windows and macOS

* Fix: npm prepare script on Windows (refs #166)

The previous script worked on macOS and Linux, but I neglected to
consider Windows. This wouldn't affect users thankfully, only
developers, so the blast radius would have been small had it not been
caught. Now that we're testing on Windows, future bugs like this should
be caught. I'm out of ideas for doing this entirely inside npm scripts,
so I broke down and did it in JS.

* Chore: Increase test timeout for Windows and macOS runners

They occasionally exhibit extremely slow filesystem performance.

* Add npm-prepare script JSDoc header
  • Loading branch information
btmills committed Dec 20, 2020
1 parent 23ac2b9 commit 1dd7089
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,16 @@ jobs:

test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
node-version: ["8.10.0", 8.x, 10.x, 12.x, 13.x, 14.x]
include:
- os: windows-latest
node: "12.x"
- os: macOS-latest
node: "12.x"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v1
Expand Down
20 changes: 20 additions & 0 deletions npm-prepare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* @fileoverview Install examples' dependencies as part of local npm install for
* development and CI.
* @author btmills
*/

"use strict";

const childProcess = require("child_process");
const fs = require("fs");
const path = require("path");

const examplesDir = path.resolve(__dirname, "examples");
const examples = fs.readdirSync(examplesDir);

for (const example of examples) {
childProcess.execSync("npm install", {
cwd: path.resolve(examplesDir, example)
});
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"scripts": {
"lint": "eslint --ext js,md .",
"prepare": "for example in examples/*; do (cd \"$example\" && npm install); done",
"prepare": "node ./npm-prepare.js",
"test": "npm run lint && npm run test-cov",
"test-cov": "nyc _mocha -- -c tests/{examples,lib}/**/*.js",
"generate-release": "eslint-generate-release",
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe("recommended config", () => {
// hook-level timeouts uses `this`, so disable the rule.
// https://mochajs.org/#hook-level
// eslint-disable-next-line no-invalid-this
this.timeout(9999);
this.timeout(30000);

execSync("npm link && npm link eslint-plugin-markdown");
} else {
Expand Down

0 comments on commit 1dd7089

Please sign in to comment.