Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb7cfa59

Browse files
committed
load from tutorial directory when using param true
1 parent3e3d29a commitb7cfa59

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
varpath=require('path');
33
varfs=require('fs');
44
varsupportedFileTypes=['js','jsx','ts','py'];
5-
varjs=/^\/\/\s?load\(['"`](.+)['"`]\)$/m;
5+
varjs=/^\/\/\s?load\(['"`](.+)['"`](\,\s?true)?\)/m;
66
varloaderMatch={
77
js:js,
88
ts:js,
99
jsx:js,
10-
py:/^#\s?load\(['"`](.+)['"`]\)$/m
10+
py:/^#\s?load\(['"`](.+)['"`](,\s?true)?\)/m
1111
};
1212
functionparseLoaders(data,fileType){
1313
if(supportedFileTypes.indexOf(fileType)<0){
@@ -26,7 +26,13 @@ function parseLoaders(data, fileType) {
2626
console.log("\""+fileToLoad+"\" already loaded.");
2727
continue;
2828
}
29-
varpathToFile=path.normalize(path.join(window.coderoad.dir,fileToLoad));
29+
varpathToFile=null;
30+
if(loader[2]){
31+
pathToFile=path.normalize(path.join(window.coderoad.tutorialDir,fileToLoad));
32+
}
33+
else{
34+
pathToFile=path.normalize(path.join(window.coderoad.dir,fileToLoad));
35+
}
3036
lines[i]=fs.readFileSync(pathToFile,'utf8');
3137
}
3238
}

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import * as path from 'path';
22
import*asfsfrom'fs';
33

44
constsupportedFileTypes=['js','jsx','ts','py'];
5-
constjs=/^\/\/\s?load\(['"`](.+)['"`]\)$/m;// // load('file'),
5+
constjs=/^\/\/\s?load\(['"`](.+)['"`](\,\s?true)?\)/m;// // load('file'),
66
constloaderMatch={
77
js,
88
ts:js,
99
jsx:js,
10-
py:/^#\s?load\(['"`](.+)['"`]\)$/m// # load('file')
10+
py:/^#\s?load\(['"`](.+)['"`](,\s?true)?\)/m// # load('file')
1111
};
1212

1313
exportdefaultfunctionparseLoaders(data:string,fileType:string){
@@ -36,7 +36,15 @@ export default function parseLoaders(data: string, fileType: string) {
3636
continue;
3737
}
3838

39-
letpathToFile:string=path.normalize(path.join(window.coderoad.dir,fileToLoad));
39+
letpathToFile:string=null;
40+
if(loader[2]){
41+
// path to file from tutorial directory
42+
pathToFile=path.normalize(path.join(window.coderoad.tutorialDir,fileToLoad));
43+
}else{
44+
// path to file from working directory
45+
pathToFile=path.normalize(path.join(window.coderoad.dir,fileToLoad));
46+
}
47+
4048
lines[i]=fs.readFileSync(pathToFile,'utf8');
4149
}
4250
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp