testaro 6.0.1 → 6.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/watch.js +18 -13
package/package.json
CHANGED
package/watch.js
CHANGED
|
@@ -37,22 +37,27 @@ const reportDir = process.env.REPORTDIR;
|
|
|
37
37
|
|
|
38
38
|
// Checks for a directory job.
|
|
39
39
|
const checkDirJob = async () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
try {
|
|
41
|
+
const jobDirFileNames = await fs.readdir(watchDir);
|
|
42
|
+
const jobFileNames = jobDirFileNames.filter(fileName => fileName.endsWith('.json'));
|
|
43
|
+
if (jobFileNames.length) {
|
|
44
|
+
const scriptJSON = await fs.readFile(`${watchDir}/${jobFileNames[0]}`, 'utf8');
|
|
45
|
+
try {
|
|
46
|
+
const script = JSON.parse(scriptJSON, null, 2);
|
|
47
|
+
return script;
|
|
48
|
+
}
|
|
49
|
+
catch(error) {
|
|
50
|
+
return {
|
|
51
|
+
error: 'ERROR: Script was not JSON',
|
|
52
|
+
message: error.message
|
|
53
|
+
};
|
|
54
|
+
}
|
|
47
55
|
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
error: 'ERROR: Script was not JSON',
|
|
51
|
-
message: error.message
|
|
52
|
-
};
|
|
56
|
+
else {
|
|
57
|
+
return {};
|
|
53
58
|
}
|
|
54
59
|
}
|
|
55
|
-
|
|
60
|
+
catch {
|
|
56
61
|
return {};
|
|
57
62
|
}
|
|
58
63
|
};
|