testaro 8.1.1 → 8.1.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/call.js +0 -1
- package/package.json +1 -1
- package/watch.js +17 -13
package/call.js
CHANGED
|
@@ -39,7 +39,6 @@ const callWatch = async (isDirWatch, isForever, interval) => {
|
|
|
39
39
|
`Starting a ${isForever === 'true' ? 'repeating' : 'one-time'} ${isDirWatch === 'true' ? 'directory' : 'network'} watch`
|
|
40
40
|
);
|
|
41
41
|
await cycle(isDirWatch === 'true', isForever === 'true', Number.parseInt(interval, 10));
|
|
42
|
-
console.log('Watching ended');
|
|
43
42
|
};
|
|
44
43
|
|
|
45
44
|
// ########## OPERATION
|
package/package.json
CHANGED
package/watch.js
CHANGED
|
@@ -85,11 +85,11 @@ const checkNetJob = async () => {
|
|
|
85
85
|
};
|
|
86
86
|
// Writes a directory report.
|
|
87
87
|
const writeDirReport = async report => {
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
88
|
+
const jobID = report && report.job && report.job.id;
|
|
89
|
+
if (jobID) {
|
|
90
90
|
try {
|
|
91
91
|
const reportJSON = JSON.stringify(report, null, 2);
|
|
92
|
-
const reportName = `${
|
|
92
|
+
const reportName = `${jobID}.json`;
|
|
93
93
|
await fs.writeFile(`${reportDir}/${reportName}`, reportJSON);
|
|
94
94
|
console.log(`Report ${reportName} saved`);
|
|
95
95
|
return true;
|
|
@@ -99,6 +99,10 @@ const writeDirReport = async report => {
|
|
|
99
99
|
return false;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
+
else {
|
|
103
|
+
console.log('ERROR: Job has no ID');
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
102
106
|
};
|
|
103
107
|
// Submits a network report.
|
|
104
108
|
const writeNetReport = async report => {
|
|
@@ -130,10 +134,10 @@ const writeNetReport = async report => {
|
|
|
130
134
|
return ack;
|
|
131
135
|
};
|
|
132
136
|
// Archives a job.
|
|
133
|
-
const archiveJob = async
|
|
134
|
-
const
|
|
135
|
-
await fs.writeFile(`${doneDir}/${
|
|
136
|
-
await fs.rm(`${jobDir}/${
|
|
137
|
+
const archiveJob = async job => {
|
|
138
|
+
const jobJSON = JSON.stringify(job, null, 2);
|
|
139
|
+
await fs.writeFile(`${doneDir}/${job.id}.json`, jobJSON);
|
|
140
|
+
await fs.rm(`${jobDir}/${job.id}.json`);
|
|
137
141
|
};
|
|
138
142
|
// Waits.
|
|
139
143
|
const wait = ms => {
|
|
@@ -144,15 +148,15 @@ const wait = ms => {
|
|
|
144
148
|
});
|
|
145
149
|
};
|
|
146
150
|
// Runs a job and returns a report.
|
|
147
|
-
exports.runJob = async (
|
|
148
|
-
const {id} =
|
|
151
|
+
exports.runJob = async (job, isDirWatch) => {
|
|
152
|
+
const {id} = job;
|
|
149
153
|
if (id) {
|
|
150
154
|
try {
|
|
151
155
|
// Initialize a report.
|
|
152
156
|
const report = {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
job,
|
|
158
|
+
acts: [],
|
|
159
|
+
jobData: {}
|
|
156
160
|
};
|
|
157
161
|
// Run the job, adding to the report.
|
|
158
162
|
await doJob(report);
|
|
@@ -218,7 +222,7 @@ exports.cycle = async (isDirWatch, isForever, interval) => {
|
|
|
218
222
|
if (isDirWatch) {
|
|
219
223
|
// Archive the job.
|
|
220
224
|
await archiveJob(job);
|
|
221
|
-
console.log(`
|
|
225
|
+
console.log(`Job ${job.id} archived`);
|
|
222
226
|
}
|
|
223
227
|
// If watching was specified for only 1 job, stop.
|
|
224
228
|
statusOK = isForever;
|