Skip to content

Commit 4fc613c

Browse files
committed
update for windows
1 parent 0fe28fe commit 4fc613c

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

lib/runner/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
"use strict";
22
var start_runner_1 = require('./start-runner');
33
var runner_process_1 = require('./runner-process');
4+
var isWindows = window.navigator.appVersion.indexOf('Win') > -1;
45
function runner(_a) {
56
var dir = _a.dir, taskPosition = _a.taskPosition, handleResult = _a.handleResult, testPath = _a.testPath;
7+
if (isWindows) {
8+
testPath = testPath.split('\\').join('\\\\');
9+
testPath = testPath.split('/').join('\\\\');
10+
}
611
var runner = runner_process_1.default({ dir: dir, taskPosition: taskPosition, testPath: testPath });
712
return start_runner_1.default({ runner: runner, handleResult: handleResult, taskPosition: taskPosition });
813
}

lib/testPath.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
var path_1 = require('path');
3-
var isWindows = window.navigator.appVersion.indexOf('Win') > -1 || false;
3+
var isWindows = window.navigator.appVersion.includes('Win') || false;
44
function tmpTestName(testFile) {
55
var testPath = path_1.join(__dirname, '..', '.tmp', testFile + '.js');
66
if (isWindows) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"test": "echo \"Error: no test specified\" && exit 1"
2727
},
2828
"dependencies": {
29-
"js-coderoad": "^0.1.3",
29+
"js-coderoad": "^0.1.4",
3030
"mocha": "^3.0.2",
3131
"node-file-exists": "1.1.0"
3232
},

src/runner/index.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import startRunner from './start-runner';
22
import spawnRunnerProcess from './runner-process';
33

4+
const isWindows = window.navigator.appVersion.indexOf('Win') > -1;
5+
46
export default function runner({dir, taskPosition, handleResult, testPath}) {
5-
const runner = spawnRunnerProcess({dir, taskPosition, testPath});
6-
return startRunner({runner, handleResult, taskPosition});
7+
8+
if (isWindows) {
9+
testPath = testPath.split('\\').join('\\\\');
10+
testPath = testPath.split('/').join('\\\\');
11+
}
12+
13+
const runner = spawnRunnerProcess({dir, taskPosition, testPath});
14+
return startRunner({runner, handleResult, taskPosition});
715
}

src/testPath.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { join } from 'path';
22

3-
const isWindows = window.navigator.appVersion.indexOf('Win') > -1 || false;
3+
const isWindows = window.navigator.appVersion.includes('Win') || false;
44

55
export default function tmpTestName(testFile: string): string {
66
let testPath = join(__dirname, '..', '.tmp', testFile + '.js');
7-
// fix bug on Windows for test paths
87
if (isWindows) {
98
testPath = testPath.split('/').join('\\');
109
}

0 commit comments

Comments
 (0)