Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a8b4987

Browse files
committed
add scan-dependency step in js test-runner
1 parent 12cf973 commit a8b4987

File tree

1 file changed

+32
-5
lines changed
  • plotly/tests/test_core/test_jupyter/lib

1 file changed

+32
-5
lines changed

plotly/tests/test_core/test_jupyter/lib/server.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,27 @@ var PATH_TEST_BUNDLE = path.join(PATH_ROOT, 'test.tmp.js');
1818
var URL = 'http://localhost:' + PORT + '/fixtures/test.tmp.html';
1919
var EXIT_CODE = 0;
2020

21-
// main
22-
stubIndex()
23-
.then(bundleTests)
24-
.then(startServer)
25-
.then(launch)
21+
22+
main();
23+
24+
function main() {
25+
scanDependencies();
26+
27+
stubIndex()
28+
.then(bundleTests)
29+
.then(startServer)
30+
.then(launch);
31+
}
32+
33+
function scanDependencies() {
34+
var reqFiles = [PATH_INDEX, PATH_TEST_FILE];
35+
36+
reqFiles.forEach(function(filePath) {
37+
if(!doesFileExist(filePath)) {
38+
throw new Error(filePath + ' does not exist');
39+
}
40+
});
41+
}
2642

2743
function stubIndex() {
2844
return new Promise(function(resolve, reject) {
@@ -87,6 +103,17 @@ function launch() {
87103
chrome(URL);
88104
}
89105

106+
function doesFileExist(filePath) {
107+
try {
108+
if(fs.statSync(filePath).isFile()) return true;
109+
}
110+
catch(e) {
111+
return false;
112+
}
113+
114+
return false;
115+
}
116+
90117
function removeBuildFiles() {
91118
fs.unlinkSync(PATH_INDEX_STUB);
92119
fs.unlinkSync(PATH_TEST_BUNDLE);

0 commit comments

Comments
 (0)