Skip to content

Commit d123ec3

Browse files
committed
load parser fixes
1 parent 9cbf8f8 commit d123ec3

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
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');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "atom-coderoad",
33
"main": "./lib/atom/main",
4-
"version": "0.6.0",
4+
"version": "0.5.5",
55
"description": "Interactive tutorial plugin for Atom",
66
"author": "Shawn McKay <shawn.j.mckay@gmail.com>",
77
"keywords": [

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)