Skip to content

Commit 8866ba3

Browse files
committed
fix(cucumbertemplate): dynamically create require paths on win32 as well as other platforms
fix #291
1 parent 83cea5c commit 8866ba3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

lib/cucumberTemplate.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
const path = require("path");
2+
const os = require("os");
3+
4+
const getPathFor = file => {
5+
if (os.platform() === "win32") {
6+
const pathParts = __dirname.split("\\");
7+
return path.join(...pathParts, file).replace(/\\/g, "\\\\");
8+
}
9+
return `${__dirname}/${file}`;
10+
};
11+
112
exports.cucumberTemplate = `
213
const {
314
resolveAndRunStepDefinition,
@@ -10,7 +21,7 @@ const {
1021
Before,
1122
After,
1223
defineStep
13-
} = require("${__dirname}/resolveStepDefinition");
24+
} = require("${getPathFor("resolveStepDefinition")}");
1425
const Given = (window.Given = window.given = given);
1526
const When = (window.When = window.when = when);
1627
const Then = (window.Then = window.then = then);
@@ -20,5 +31,5 @@ window.defineParameterType = defineParameterType;
2031
window.defineStep = defineStep;
2132
const {
2233
createTestsFromFeature
23-
} = require("${__dirname}/createTestsFromFeature");
34+
} = require("${getPathFor("createTestsFromFeature")}");
2435
`;

0 commit comments

Comments
 (0)