Skip to content

Commit e25d9a2

Browse files
committed
further fixes for windows
1 parent e0a4381 commit e25d9a2

File tree

9 files changed

+27
-7
lines changed

9 files changed

+27
-7
lines changed

lib/atom/editor.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ var exists_1 = require('../services/exists');
44
function setAtomGlobals() {
55
if (atom.project.rootDirectories.length > 0) {
66
window.coderoad.dir = atom.project.rootDirectories[0].path;
7+
if (navigator.appVersion.indexOf('Win') > -1) {
8+
window.coderoad.win = true;
9+
}
710
}
811
else {
912
window.coderoad.dir = null;

lib/reducers/task-tests/concat-tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use strict";
22
var fs = require('fs');
33
function concatTests(targetFile, files) {
4+
console.log('files', files);
45
if (fs.existsSync(targetFile)) {
56
fs.unlink(targetFile);
67
}

lib/services/package.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ var Action = require('../actions/actions');
55
var _base_1 = require('../_base');
66
var _ = require('lodash');
77
function configTestString(config, packageName, test) {
8+
if (window.coderoad.win) {
9+
test = test.split('/').join('\\');
10+
}
811
if (config.testDir) {
912
test = path.join(window.coderoad.dir, 'node_modules', packageName, config.testDir, test);
1013
}
@@ -45,7 +48,7 @@ var PackageService = (function () {
4548
return !tasks ? [] : tasks.map(function (task) {
4649
if (task.tests) {
4750
task.tests = task.tests.map(function (test) {
48-
if (_.isString(test) && task.tests.indexOf(test) === -1) {
51+
if (_.isString(test)) {
4952
return configTestString(config, _this.packageName, test);
5053
}
5154
else {

lib/services/setGlobals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function loadRunnerDep(config) {
3030
console.log(message);
3131
throw message;
3232
}
33-
var slash = navigator.appVersion.indexOf('Win') !== -1 ? '\\' : '/';
33+
var slash = window.coderoad.win ? '\\' : '/';
3434
runnerMain = path.join.apply(null, runnerMain.split(slash));
3535
runnerRoot = runnerRoot.substring(0, runnerRoot.lastIndexOf(slash));
3636
var pathToMain = path.join(runnerRoot, runnerMain);

src/atom/editor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import {fileExists} from '../services/exists';
44
export function setAtomGlobals() {
55
if (atom.project.rootDirectories.length > 0) {
66
window.coderoad.dir = atom.project.rootDirectories[0].path;
7+
if (navigator.appVersion.indexOf('Win') > -1) {
8+
window.coderoad.win = true;
9+
}
710
} else {
811
window.coderoad.dir = null;
912
}

src/reducers/task-tests/concat-tests.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
import * as fs from 'fs';
22

33
export function concatTests(targetFile: string, files: any): string {
4+
console.log('files', files);
45
// delete previous file
56
if (fs.existsSync(targetFile)) {
67
fs.unlink(targetFile);
78
}
89

910
// load tests in order
10-
files.forEach((test: string) => readAppend(targetFile, test));
11+
files.forEach((test: string) => {
12+
// ensure loaded synchronously
13+
return new Promise((resolve, reject) => {
14+
resolve(readAppend(targetFile, test));
15+
});
16+
});
1117
return targetFile;
1218
}
1319

14-
function readAppend(targetFile: string, file: string): void {
20+
function readAppend(targetFile: string, file: string): boolean {
1521
try {
1622
let data = fs.readFileSync(file, 'utf8');
1723
fs.appendFileSync(targetFile, data, 'utf8');
18-
return;
24+
return true;
1925
} catch (e) {
2026
console.log('Error reading test file', e);
2127
}

src/services/package.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import {store} from '../_base';
55
const _ = require('lodash');
66

77
function configTestString(config: CR.Config, packageName: string, test: string): string {
8+
if (window.coderoad.win) {
9+
test = test.split('/').join('\\');
10+
}
811
if (config.testDir) {
912
test = path.join(window.coderoad.dir, 'node_modules', packageName, config.testDir, test);
1013
} else {
@@ -47,7 +50,7 @@ class PackageService {
4750
if (task.tests) {
4851
task.tests = task.tests.map((test: string) => {
4952
// add unique string to tests
50-
if (_.isString(test) && task.tests.indexOf(test) === -1) {
53+
if (_.isString(test)) {
5154
return configTestString(config, this.packageName, test);
5255
} else {
5356
console.error('Invalid task test', test);

src/services/setGlobals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function loadRunnerDep(config: PackageJson) {
3434
}
3535

3636
// fix main path for Windows
37-
let slash = navigator.appVersion.indexOf('Win') !== -1 ? '\\' : '/';
37+
let slash = window.coderoad.win ? '\\' : '/';
3838
runnerMain = path.join.apply(null, runnerMain.split(slash));
3939
// trim root path to folder
4040
runnerRoot = runnerRoot.substring(0, runnerRoot.lastIndexOf(slash));

src/typings/cr/cr.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ declare namespace CR {
109109
edit?: boolean;
110110
runner?: any;
111111
taskPosition?: number;
112+
win?: boolean;
112113
}
113114

114115
interface Config {

0 commit comments

Comments
 (0)