Skip to content

Commit 06a5999

Browse files
committed
load parser fixes
1 parent 9cbf8f8 commit 06a5999

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

lib/reducers/run-tests/parse-loaders.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function loaderRegex(fileType) {
99
if (comments[fileType]) {
1010
comment = comments[fileType];
1111
}
12-
return new RegExp("^" + comment + " ?load\\(['\"](.+)['\"](,s?true)?\\)", 'm');
12+
return new RegExp("^" + comment + " ?load\\(['\"](.+)['\"](, ?true)?\\)", 'm');
1313
}
1414
function parseLoaders(data, fileType) {
1515
var i = -1;
@@ -32,7 +32,14 @@ function parseLoaders(data, fileType) {
3232
else {
3333
pathToFile = path.normalize(path.join(window.coderoad.dir, fileToLoad));
3434
}
35-
lines[i] = fs.readFileSync(pathToFile, 'utf8');
35+
try {
36+
lines[i] = fs.readFileSync(pathToFile, 'utf8');
37+
}
38+
catch (e) {
39+
var message = 'File not found: ' + pathToFile;
40+
lines[i] = message;
41+
console.log(message);
42+
}
3643
}
3744
}
3845
return lines.join('\n');

src/reducers/run-tests/parse-loaders.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function loaderRegex(fileType: string) {
1111
if (comments[fileType]) {
1212
comment = comments[fileType];
1313
}
14-
return new RegExp(`^${comment} ?load\\(['"](.+)['"](\,\s?true)?\\)`, 'm');
14+
return new RegExp(`^${comment} ?load\\(['"](.+)['"](\, ?true)?\\)`, 'm');
1515
}
1616

1717
export default function parseLoaders(data: string, fileType: string) {
@@ -45,7 +45,13 @@ export default function parseLoaders(data: string, fileType: string) {
4545
pathToFile = path.normalize(path.join(window.coderoad.dir, fileToLoad));
4646
}
4747

48-
lines[i] = fs.readFileSync(pathToFile, 'utf8');
48+
try {
49+
lines[i] = fs.readFileSync(pathToFile, 'utf8');
50+
} catch (e) {
51+
let message = 'File not found: ' + pathToFile;
52+
lines[i] = message;
53+
console.log(message);
54+
}
4955
}
5056
}
5157
return lines.join('\n');

0 commit comments

Comments
 (0)