Skip to content

Commit 0307ad1

Browse files
committed
fix repeatedly configured tutorial paths bug
1 parent 2afc497 commit 0307ad1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/modules/tutorial/reducer.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const _tutorial: CR.Tutorial = {
1111
config: null,
1212
};
1313

14+
const configured = [];
15+
1416
export default function tutorialReducer(
1517
t = _tutorial, action: Action
1618
): CR.Tutorial {
@@ -27,8 +29,11 @@ export default function tutorialReducer(
2729
const coderoadJsonPath = join(packagePath, packageJson.main);
2830
let {info, pages} = require(coderoadJsonPath);
2931

30-
// configure test paths to absolute paths
31-
pages = configPaths(dir, name, config, pages || []);
32+
// configure test paths to absolute paths. Only once.
33+
if (configured.indexOf(name) === -1) {
34+
pages = configPaths(dir, name, config, pages || []);
35+
}
36+
configured.push(name);
3237

3338
// return tutorial (info, pages) & tutorial package.json
3439
return {

src/modules/tutorial/utils/config-paths.ts

+4
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@ function configTestString(
66
): string {
77

88
if (isWindows) {
9+
// adjust paths for windows slashes
910
testPath = testPath.split('/').join('\\');
1011
}
1112

13+
// adjust absolute file path
1214
if (config.dir) {
1315
testPath = join(config.dir, testPath);
1416
} else {
1517
testPath = join(dir, 'node_modules', name, testPath);
1618
}
1719

1820
if (config.testSuffix) {
21+
// prevent repeat appending test suffix
1922
testPath += config.testSuffix;
2023
}
24+
2125
return testPath;
2226
}
2327

0 commit comments

Comments
 (0)