Skip to content

Commit

Permalink
Fix: npm prepare script on Windows (refs #166)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
btmills committed Dec 16, 2020
1 parent 669bdc9 commit c2dcea2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions npm-prepare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"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

0 comments on commit c2dcea2

Please sign in to comment.