Skip to content

Commit 35645e6

Browse files
Trying to get tests working on Windows
1 parent 07b0ccf commit 35645e6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

test/specs/version-hooks.spec.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22

33
const fs = require("fs");
4+
const path = require("path");
45
const cli = require("../fixtures/cli");
56
const mocks = require("../fixtures/mocks");
67
const files = require("../fixtures/files");
@@ -12,12 +13,16 @@ chai.should();
1213
describe.only("npm version hooks", () => {
1314
before("Delete npm.cmd from node_modules on Windows", () => {
1415
if (process.platform === "win32") {
15-
fs.unlinkSync("node_modules\\.bin\\npm");
16-
fs.unlinkSync("node_modules\\.bin\\npm.js");
17-
fs.unlinkSync("node_modules\\.bin\\npm.cmd");
18-
fs.unlinkSync("node_modules\\.bin\\npm-cli");
19-
fs.unlinkSync("node_modules\\.bin\\npm-cli.js");
20-
fs.unlinkSync("node_modules\\.bin\\npm-cli.cmd");
16+
let npmNames = ["npm", "npm.js", "npm.cmd", "npm-cli", "npm-cli.js", "npm-cli.cmd"];
17+
for (let npmName of npmNames) {
18+
try {
19+
fs.unlinkSync(path.join("node_modules", ".bin", npmName));
20+
console.log(`Deleting ${npmName}: SUCCESS`);
21+
}
22+
catch (error) {
23+
console.log(`Deleting ${npmName}: ${error.message}`);
24+
}
25+
}
2126
}
2227
});
2328

0 commit comments

Comments
 (0)