testaro 30.0.8 → 32.0.1
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/CONTRIBUTING.md +26 -4
- package/LICENSE +1 -1
- package/README.md +24 -2
- package/aceconfig.js +27 -0
- package/actSpecs.js +28 -1
- package/call.js +22 -1
- package/data/template.js +22 -0
- package/dirWatch.js +22 -0
- package/package.json +1 -1
- package/procs/aslint.js +24 -0
- package/procs/getLocatorData.js +29 -1
- package/procs/getSource.js +30 -3
- package/procs/isInlineLink.js +23 -0
- package/procs/operable.js +23 -2
- package/procs/sample.js +22 -0
- package/procs/standardize.js +28 -7
- package/procs/tellServer.js +24 -2
- package/procs/testaro.js +26 -1
- package/procs/visChange.js +22 -0
- package/run.js +373 -83
- package/testaro/allCaps.js +22 -0
- package/testaro/allHidden.js +22 -0
- package/testaro/allSlanted.js +22 -0
- package/testaro/attVal.js +22 -0
- package/testaro/autocomplete.js +22 -0
- package/testaro/bulk.js +22 -0
- package/testaro/buttonMenu.js +22 -0
- package/testaro/distortion.js +22 -0
- package/testaro/docType.js +22 -0
- package/testaro/dupAtt.js +22 -0
- package/testaro/elements.js +22 -0
- package/testaro/embAc.js +22 -0
- package/testaro/filter.js +22 -0
- package/testaro/focAll.js +22 -0
- package/testaro/focInd.js +22 -0
- package/testaro/focOp.js +22 -0
- package/testaro/focVis.js +22 -0
- package/testaro/headEl.js +22 -0
- package/testaro/headingAmb.js +22 -0
- package/testaro/hovInd.js +21 -24
- package/testaro/hover.js +22 -0
- package/testaro/labClash.js +22 -0
- package/testaro/lineHeight.js +22 -0
- package/testaro/linkAmb.js +22 -0
- package/testaro/linkTitle.js +22 -0
- package/testaro/linkUl.js +22 -0
- package/testaro/miniText.js +22 -0
- package/testaro/motion.js +22 -0
- package/testaro/nonTable.js +22 -0
- package/testaro/opFoc.js +22 -0
- package/testaro/pseudoP.js +25 -3
- package/testaro/radioSet.js +22 -0
- package/testaro/role.js +22 -0
- package/testaro/styleDiff.js +80 -1
- package/testaro/tabNav.js +99 -2
- package/testaro/targetSize.js +22 -0
- package/testaro/textNodes.js +25 -3
- package/testaro/title.js +22 -0
- package/testaro/zIndex.js +22 -0
- package/tests/alfa.js +34 -12
- package/tests/aslint.js +55 -17
- package/tests/axe.js +35 -9
- package/tests/htmlcs.js +109 -78
- package/tests/ibm.js +111 -45
- package/tests/nuVal.js +39 -9
- package/tests/qualWeb.js +49 -25
- package/tests/testaro.js +50 -22
- package/tests/wave.js +36 -10
- package/validation/executors/run.js +26 -2
- package/validation/executors/test.js +27 -3
- package/validation/executors/tests.js +26 -2
- package/validation/executors/watchDir.js +26 -2
- package/validation/executors/watchNet.js +26 -2
- package/validation/jobs/todo/README.md +22 -0
- package/validation/tests/targets/adbID/index.html +21 -0
- package/validation/tests/targets/allCaps/index.html +21 -0
- package/validation/tests/targets/allHidden/ariaHiddenBody.html +21 -0
- package/validation/tests/targets/allHidden/good.html +21 -0
- package/validation/tests/targets/allHidden/hiddenMain.html +21 -0
- package/validation/tests/targets/allHidden/mixedHidden.html +22 -1
- package/validation/tests/targets/allHidden/noBody.html +21 -0
- package/validation/tests/targets/allHidden/noMain.html +21 -0
- package/validation/tests/targets/allHidden/noneDoc.html +21 -0
- package/validation/tests/targets/allHidden/visHiddenMain.html +21 -0
- package/validation/tests/targets/allSlanted/index.html +21 -0
- package/validation/tests/targets/altScheme/index.html +21 -0
- package/validation/tests/targets/attVal/bad.html +21 -0
- package/validation/tests/targets/attVal/good.html +21 -0
- package/validation/tests/targets/autocomplete/bad.html +21 -0
- package/validation/tests/targets/autocomplete/good.html +21 -0
- package/validation/tests/targets/bulk/bad.html +21 -0
- package/validation/tests/targets/bulk/good.html +21 -0
- package/validation/tests/targets/buttonMenu/bad.html +21 -0
- package/validation/tests/targets/buttonMenu/bad.js +27 -0
- package/validation/tests/targets/buttonMenu/good.html +21 -0
- package/validation/tests/targets/buttonMenu/good.js +27 -0
- package/validation/tests/targets/buttonMenu/style.css +27 -0
- package/validation/tests/targets/captionLoc/index.html +21 -0
- package/validation/tests/targets/datalistRef/index.html +21 -0
- package/validation/tests/targets/distortion/index.html +21 -0
- package/validation/tests/targets/docType/bad.html +21 -0
- package/validation/tests/targets/docType/good.html +21 -0
- package/validation/tests/targets/dupAtt/bad.html +21 -0
- package/validation/tests/targets/dupAtt/good.html +21 -0
- package/validation/tests/targets/elements/index.html +21 -0
- package/validation/tests/targets/embAc/bad.html +21 -0
- package/validation/tests/targets/embAc/good.html +21 -0
- package/validation/tests/targets/filter/bad.html +21 -0
- package/validation/tests/targets/filter/good.html +21 -0
- package/validation/tests/targets/focAll/good.html +21 -0
- package/validation/tests/targets/focAll/less.html +21 -0
- package/validation/tests/targets/focAll/more.html +21 -0
- package/validation/tests/targets/focInd/bad.html +21 -0
- package/validation/tests/targets/focInd/good.html +21 -0
- package/validation/tests/targets/focOp/bad.html +21 -0
- package/validation/tests/targets/focOp/good.html +21 -0
- package/validation/tests/targets/focVis/index.html +21 -0
- package/validation/tests/targets/headEl/index.html +21 -0
- package/validation/tests/targets/headingAmb/index.html +21 -0
- package/validation/tests/targets/hovInd/index.html +21 -0
- package/validation/tests/targets/hover/bad.html +21 -0
- package/validation/tests/targets/hover/good.html +21 -0
- package/validation/tests/targets/hr/index.html +21 -0
- package/validation/tests/targets/imageLink/index.html +21 -0
- package/validation/tests/targets/labClash/bad.html +21 -0
- package/validation/tests/targets/labClash/good.html +21 -0
- package/validation/tests/targets/legendLoc/index.html +21 -0
- package/validation/tests/targets/lineHeight/index.html +21 -0
- package/validation/tests/targets/linkAmb/index.html +21 -0
- package/validation/tests/targets/linkExt/index.html +21 -0
- package/validation/tests/targets/linkOldAtt/index.html +21 -0
- package/validation/tests/targets/linkTitle/index.html +21 -0
- package/validation/tests/targets/linkTo/index.html +21 -0
- package/validation/tests/targets/linkUl/bad.html +21 -0
- package/validation/tests/targets/linkUl/good.html +21 -0
- package/validation/tests/targets/linkUl/na.html +21 -0
- package/validation/tests/targets/miniText/index.html +21 -0
- package/validation/tests/targets/motion/bad.css +27 -0
- package/validation/tests/targets/motion/bad.html +21 -0
- package/validation/tests/targets/motion/good.html +21 -0
- package/validation/tests/targets/nonTable/index.html +21 -0
- package/validation/tests/targets/opFoc/bad.html +21 -0
- package/validation/tests/targets/opFoc/good.html +21 -0
- package/validation/tests/targets/optRoleSel/index.html +21 -0
- package/validation/tests/targets/phOnly/index.html +21 -0
- package/validation/tests/targets/pseudoP/index.html +21 -0
- package/validation/tests/targets/radioSet/bad.html +21 -0
- package/validation/tests/targets/radioSet/good.html +21 -0
- package/validation/tests/targets/role/bad.html +21 -0
- package/validation/tests/targets/role/good.html +21 -0
- package/validation/tests/targets/secHeading/index.html +21 -0
- package/validation/tests/targets/styleDiff/bad.html +21 -0
- package/validation/tests/targets/styleDiff/good.html +21 -0
- package/validation/tests/targets/tabNav/bad.html +21 -0
- package/validation/tests/targets/tabNav/bad.js +27 -0
- package/validation/tests/targets/tabNav/good.html +21 -0
- package/validation/tests/targets/tabNav/good.js +27 -0
- package/validation/tests/targets/tabNav/style.css +27 -0
- package/validation/tests/targets/targetSize/index.html +21 -0
- package/validation/tests/targets/textNodes/index.html +21 -0
- package/validation/tests/targets/textSem/index.html +21 -0
- package/validation/tests/targets/title/bad.html +21 -0
- package/validation/tests/targets/title/good.html +21 -0
- package/validation/tests/targets/titledEl/index.html +21 -0
- package/validation/tests/targets/zIndex/bad.html +21 -0
- package/validation/tests/targets/zIndex/good.html +21 -0
- package/validation/validateTest.js +39 -3
- package/validation/watch/done/README.md +23 -1
- package/validation/watch/todo/README.md +23 -1
- package/watch.js +32 -7
- package/call-old.js +0 -86
- package/procs/allText.js +0 -76
- package/procs/allVis.js +0 -17
- package/procs/getTextNodes.js +0 -39
- package/procs/linksByType.js +0 -54
- package/procs/nav.js +0 -259
- package/procs/textOf.txt +0 -73
- package/test copy.js +0 -38
- package/validation/tests/old/allCaps.json +0 -102
- package/validation/tests/old/allHidden.json +0 -314
- package/validation/tests/old/attVal.json +0 -60
- package/validation/tests/old/autocomplete.json +0 -51
- package/validation/tests/old/bulk.json +0 -48
- package/validation/tests/old/docType.json +0 -46
- package/validation/tests/old/dupAtt.json +0 -51
- package/validation/tests/old/elements.json +0 -140
- package/validation/tests/old/embAc.json +0 -54
- package/validation/tests/old/filter.json +0 -55
- package/validation/tests/old/focAll.json +0 -68
- package/validation/tests/old/focInd.json +0 -69
- package/validation/tests/old/focOp.json +0 -62
- package/validation/tests/old/focVis.json +0 -35
- package/validation/tests/old/hover.json +0 -118
- package/validation/tests/old/labClash.json +0 -52
- package/validation/tests/old/linkTo.json +0 -35
- package/validation/tests/old/linkUl.json +0 -71
- package/validation/tests/old/menuNav.json +0 -106
- package/validation/tests/old/miniText.json +0 -36
- package/validation/tests/old/motion.json +0 -62
- package/validation/tests/old/nonTable.json +0 -37
- package/validation/tests/old/radioSet.json +0 -52
- package/validation/tests/old/role.json +0 -60
- package/validation/tests/old/styleDiff.json +0 -71
- package/validation/tests/old/tabNav.json +0 -106
- package/validation/tests/old/temp.js +0 -28
- package/validation/tests/old/textNodes.json +0 -98
- package/validation/tests/old/title.json +0 -46
- package/validation/tests/old/titledEl.json +0 -37
- package/validation/tests/old/zIndex.json +0 -49
- package/validation/tests/targets/tabNav/goodMoz.js +0 -206
- package/watch-old.js +0 -275
- package/watch-temp.js +0 -45
package/watch-old.js
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
watch.js
|
|
3
|
-
Module for watching for a job and running it when found.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// ########## IMPORTS
|
|
7
|
-
|
|
8
|
-
// Module to keep secrets local.
|
|
9
|
-
require('dotenv').config();
|
|
10
|
-
// Module to read and write files.
|
|
11
|
-
const fs = require('fs/promises');
|
|
12
|
-
// Module to perform tests.
|
|
13
|
-
const {doJob} = require('./run');
|
|
14
|
-
// HTTP and HTTPS clients.
|
|
15
|
-
const httpClient = require('http');
|
|
16
|
-
const httpsClient = require('https');
|
|
17
|
-
|
|
18
|
-
// ########## CONSTANTS
|
|
19
|
-
|
|
20
|
-
const jobURLs = process.env.JOB_URLs;
|
|
21
|
-
const agent = process.env.AGENT;
|
|
22
|
-
const jobDir = process.env.JOBDIR;
|
|
23
|
-
const reportDir = process.env.REPORTDIR;
|
|
24
|
-
// Get a randomized array of servers to watch from the environment.
|
|
25
|
-
const servers = jobURLs
|
|
26
|
-
.split('+')
|
|
27
|
-
.map(url => [Math.random(), url])
|
|
28
|
-
.sort((a, b) => a[0] - b[0])
|
|
29
|
-
.map(pair => pair[1]);
|
|
30
|
-
|
|
31
|
-
// ########## FUNCTIONS
|
|
32
|
-
|
|
33
|
-
// Returns a string representing the date and time.
|
|
34
|
-
const nowString = () => (new Date()).toISOString().slice(0, 19);
|
|
35
|
-
// Writes a directory report.
|
|
36
|
-
const writeDirReport = async report => {
|
|
37
|
-
const jobID = report && report.id;
|
|
38
|
-
if (jobID) {
|
|
39
|
-
try {
|
|
40
|
-
const reportJSON = JSON.stringify(report, null, 2);
|
|
41
|
-
const reportName = `${jobID}.json`;
|
|
42
|
-
const rawDir = `${reportDir}/raw`;
|
|
43
|
-
await fs.mkdir(rawDir, {recursive: true});
|
|
44
|
-
await fs.writeFile(`${rawDir}/${reportName}`, reportJSON);
|
|
45
|
-
console.log(`Report ${reportName} saved in ${rawDir}`);
|
|
46
|
-
}
|
|
47
|
-
catch(error) {
|
|
48
|
-
console.log(`ERROR: Failed to write report ${jobID} in ${rawDir} (${error.message})`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
console.log('ERROR: Job has no ID');
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
// Waits.
|
|
56
|
-
const wait = ms => {
|
|
57
|
-
return new Promise(resolve => {
|
|
58
|
-
setTimeout(() => {
|
|
59
|
-
resolve('');
|
|
60
|
-
}, ms);
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
// Archives a job.
|
|
64
|
-
const archiveJob = async job => {
|
|
65
|
-
const {id} = job;
|
|
66
|
-
const jobJSON = JSON.stringify(job, null, 2);
|
|
67
|
-
await fs.writeFile(`${jobDir}/done/${id}.json`, jobJSON);
|
|
68
|
-
await fs.rm(`${jobDir}/todo/${id}.json`);
|
|
69
|
-
};
|
|
70
|
-
// Checks for a directory job and, if found, performs and reports it, once or repeatedly.
|
|
71
|
-
const checkDirJob = async (interval) => {
|
|
72
|
-
try {
|
|
73
|
-
// If there are any jobs to do in the watched directory:
|
|
74
|
-
const toDoFileNames = await fs.readdir(`${jobDir}/todo`);
|
|
75
|
-
const jobFileNames = toDoFileNames.filter(fileName => fileName.endsWith('.json'));
|
|
76
|
-
if (jobFileNames.length) {
|
|
77
|
-
// Get the first one.
|
|
78
|
-
const jobJSON = await fs.readFile(`${jobDir}/todo/${jobFileNames[0]}`, 'utf8');
|
|
79
|
-
try {
|
|
80
|
-
const job = JSON.parse(jobJSON, null, 2);
|
|
81
|
-
const {id} = job;
|
|
82
|
-
// Perform it.
|
|
83
|
-
console.log(`Directory job ${id} found (${nowString()})`);
|
|
84
|
-
await doJob(job);
|
|
85
|
-
console.log(`Job ${id} finished (${nowString()})`);
|
|
86
|
-
// Report it.
|
|
87
|
-
await writeDirReport(job);
|
|
88
|
-
// Archive it.
|
|
89
|
-
await archiveJob(job);
|
|
90
|
-
console.log(`Job ${id} archived in ${jobDir} (${nowString()})`);
|
|
91
|
-
// If watching is repetitive:
|
|
92
|
-
if (interval > -1) {
|
|
93
|
-
// Wait for the specified interval.
|
|
94
|
-
await wait(1000 * interval);
|
|
95
|
-
// Check the servers again.
|
|
96
|
-
checkDirJob(interval);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
catch(error) {
|
|
100
|
-
console.log(`ERROR processing directory job (${error.message})`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
// Otherwise, i.e. if there are no more jobs to do in the watched directory:
|
|
104
|
-
else {
|
|
105
|
-
console.log(`No job to do in ${jobDir} (${nowString()})`);
|
|
106
|
-
// If checking is repetitive:
|
|
107
|
-
if (interval > -1) {
|
|
108
|
-
// Wait for the specified interval.
|
|
109
|
-
await wait(1000 * interval);
|
|
110
|
-
// Check the directory again.
|
|
111
|
-
await checkDirJob(interval);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
catch(error) {
|
|
116
|
-
console.log(`ERROR: Directory watching failed (${error.message})`);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
// Checks servers for a job and, if obtained, performs and reports it, once or repeatedly.
|
|
120
|
-
const checkNetJob = async (serverIndex, interval) => {
|
|
121
|
-
// If any servers remain to be checked:
|
|
122
|
-
if (serverIndex < servers.length) {
|
|
123
|
-
// Request a job from the indexed server.
|
|
124
|
-
const server = servers[serverIndex];
|
|
125
|
-
const logStart = `Asked ${server} for a job and got `;
|
|
126
|
-
const wholeURL = `${server}?agent=${agent}`;
|
|
127
|
-
let client = server.startsWith('https://') ? httpsClient : httpClient;
|
|
128
|
-
console.log(`About to make request to ${wholeURL}`);
|
|
129
|
-
httpClient.request(
|
|
130
|
-
'http://localhost:8000', response => console.log(JSON.stringify(response, null, 2))
|
|
131
|
-
).end();
|
|
132
|
-
/*
|
|
133
|
-
const jobRequest = client.request(wholeURL, {timeout: 1000}, response => {
|
|
134
|
-
console.log('Request made');
|
|
135
|
-
console.log(`Status: ${response.statusCode}`);
|
|
136
|
-
const chunks = [];
|
|
137
|
-
response.on('data', chunk => {
|
|
138
|
-
chunks.push(chunk);
|
|
139
|
-
})
|
|
140
|
-
// When the response is completed:
|
|
141
|
-
.on('end', async () => {
|
|
142
|
-
// If the response was JSON-formatted:
|
|
143
|
-
const responseJSON = chunks.join('');
|
|
144
|
-
try {
|
|
145
|
-
const responseObj = JSON.parse(responseJSON);
|
|
146
|
-
// If the server sent a valid job:
|
|
147
|
-
const {id, sources} = responseObj;
|
|
148
|
-
if (id && sources) {
|
|
149
|
-
const {sendReportTo} = sources;
|
|
150
|
-
if (sendReportTo) {
|
|
151
|
-
console.log(`Network job ${id} received from ${server} (${nowString()})`);
|
|
152
|
-
// Perform it.
|
|
153
|
-
await doJob(responseObj);
|
|
154
|
-
console.log(`Job ${id} finished (${nowString()})`);
|
|
155
|
-
// Send the report to the server and report its response.
|
|
156
|
-
console.log(`Sending report to ${sendReportTo}`);
|
|
157
|
-
client = sendReportTo.startsWith('https://') ? httpsClient : httpClient;
|
|
158
|
-
const request = client.request(sendReportTo, {method: 'POST'}, response => {
|
|
159
|
-
const chunks = [];
|
|
160
|
-
response.on('data', chunk => {
|
|
161
|
-
chunks.push(chunk);
|
|
162
|
-
});
|
|
163
|
-
// When the response arrives:
|
|
164
|
-
response.on('end', async () => {
|
|
165
|
-
const content = chunks.join('');
|
|
166
|
-
const logStart = `Sent report to ${sendReportTo} and got `;
|
|
167
|
-
try {
|
|
168
|
-
const ack = JSON.parse(content);
|
|
169
|
-
console.log(`${logStart}${ack}`);
|
|
170
|
-
// Archive the job.
|
|
171
|
-
await archiveJob(responseObj);
|
|
172
|
-
console.log(`Job ${id} archived (${nowString()})`);
|
|
173
|
-
// If watching is repetitive:
|
|
174
|
-
if (interval > -1) {
|
|
175
|
-
// Wait for the specified interval.
|
|
176
|
-
await wait(1000 * interval);
|
|
177
|
-
// Check the next server.
|
|
178
|
-
await checkNetJob(serverIndex + 1, interval);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
catch(error) {
|
|
182
|
-
console.log(
|
|
183
|
-
`ERROR: ${logStart}status ${response.statusCode}, error message ${error.message}, and body ${content.slice(0,1000)}`
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
})
|
|
188
|
-
.on('error', error => {
|
|
189
|
-
console.log(`ERROR submitting job report (${error.message})`);
|
|
190
|
-
});
|
|
191
|
-
report.jobData.agent = agent;
|
|
192
|
-
const reportJSON = JSON.stringify(report, null, 2);
|
|
193
|
-
request.end(reportJSON);
|
|
194
|
-
}
|
|
195
|
-
// Otherwise, if the server sent a job without a report destination:
|
|
196
|
-
else {
|
|
197
|
-
// Report this.
|
|
198
|
-
console.log(`ERROR: ${logStart}a job with no report destination`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
// Otherwise, if the server sent a message instead of a job:
|
|
202
|
-
else if (responseObj.message) {
|
|
203
|
-
// Report it.
|
|
204
|
-
console.log(`${logStart}${responseObj.message}`);
|
|
205
|
-
}
|
|
206
|
-
// Otherwise, if the server sent any other JSON response:
|
|
207
|
-
else {
|
|
208
|
-
// Report it.
|
|
209
|
-
console.log(`${logStart} ${JSON.stringify(responseObj, null, 2)}`);
|
|
210
|
-
// Check the next server.
|
|
211
|
-
await checkNetJob(serverIndex + 1, interval);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
catch(error) {
|
|
215
|
-
// Report any error.
|
|
216
|
-
console.log(
|
|
217
|
-
`${logStart}status ${response.statusCode} and reply ${responseJSON.slice(0, 1000)}`
|
|
218
|
-
);
|
|
219
|
-
// Check the next server.
|
|
220
|
-
await checkNetJob(serverIndex + 1, interval);
|
|
221
|
-
}
|
|
222
|
-
})
|
|
223
|
-
// If the response throws an error:
|
|
224
|
-
.on('error', async error => {
|
|
225
|
-
// Report it.
|
|
226
|
-
console.log(
|
|
227
|
-
`${logStart}status code ${response.statusCode} and error message ${error.message}`
|
|
228
|
-
);
|
|
229
|
-
// Check the next server.
|
|
230
|
-
await checkNetJob(serverIndex + 1, interval);
|
|
231
|
-
});
|
|
232
|
-
})
|
|
233
|
-
// If the request throws an error:
|
|
234
|
-
.on('error', async error => {
|
|
235
|
-
// Report it.
|
|
236
|
-
console.log(`${logStart} error ${error.message}`);
|
|
237
|
-
// Check the next server.
|
|
238
|
-
await checkNetJob(serverIndex + 1, interval);
|
|
239
|
-
})
|
|
240
|
-
// If the request times out:
|
|
241
|
-
.on('timeout', async () => {
|
|
242
|
-
// Report this.
|
|
243
|
-
console.log(`${logStart} a timeout`);
|
|
244
|
-
// Check the next server.
|
|
245
|
-
await checkNetJob(serverIndex + 1, interval);
|
|
246
|
-
});
|
|
247
|
-
// Close the request.
|
|
248
|
-
jobRequest.end();
|
|
249
|
-
console.log(`Request to ${server} ended`);
|
|
250
|
-
}
|
|
251
|
-
// Otherwise, i.e. if no servers remain to be checked:
|
|
252
|
-
else {
|
|
253
|
-
// If checking is repetitive:
|
|
254
|
-
if (interval > -1) {
|
|
255
|
-
// Wait for the specified interval.
|
|
256
|
-
await wait(1000 * interval);
|
|
257
|
-
// Check the servers again.
|
|
258
|
-
await checkNetJob(0, interval);
|
|
259
|
-
}
|
|
260
|
-
*/
|
|
261
|
-
}
|
|
262
|
-
};
|
|
263
|
-
// Checks for a job, performs it, and submits a report, once or repeatedly.
|
|
264
|
-
exports.watch = async (isDirWatch, interval = 300) => {
|
|
265
|
-
const intervalSpec = interval > -1 ? `repeatedly, with ${interval}-second intervals ` : '';
|
|
266
|
-
console.log(`Watching started ${intervalSpec}(${nowString()})\n`);
|
|
267
|
-
// Start the checking.
|
|
268
|
-
if (isDirWatch) {
|
|
269
|
-
await checkDirJob(interval);
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
await checkNetJob(0, interval);
|
|
273
|
-
}
|
|
274
|
-
console.log(`Watching ended (${nowString()})`);
|
|
275
|
-
};
|
package/watch-temp.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
watch.js
|
|
3
|
-
Module for watching for a job and running it when found.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
// ########## IMPORTS
|
|
7
|
-
|
|
8
|
-
const httpClient = require('http');
|
|
9
|
-
|
|
10
|
-
// ########## FUNCTIONS
|
|
11
|
-
|
|
12
|
-
// Returns a string representing the date and time.
|
|
13
|
-
const nowString = () => (new Date()).toISOString().slice(0, 19);
|
|
14
|
-
// Checks servers for a network job.
|
|
15
|
-
const checkNetJob = (serverIndex, interval) => {
|
|
16
|
-
const request = httpClient.request('http://localhost:3008/testu', response => {
|
|
17
|
-
console.log('Response fn being defined');
|
|
18
|
-
const chunks = [];
|
|
19
|
-
response.on('data', chunk => {
|
|
20
|
-
chunks.push(chunk);
|
|
21
|
-
})
|
|
22
|
-
// When response arrives:
|
|
23
|
-
.on('end', () => {
|
|
24
|
-
// Report it.
|
|
25
|
-
const content = chunks.join('');
|
|
26
|
-
console.log(content);
|
|
27
|
-
console.log(`Watching ended (${nowString()})`);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
console.log('About to close request');
|
|
31
|
-
request.end();
|
|
32
|
-
console.log('Closed request');
|
|
33
|
-
};
|
|
34
|
-
// Checks for a job, performs it, and submits a report, once or repeatedly.
|
|
35
|
-
exports.watch = async (isDirWatch, interval = 300) => {
|
|
36
|
-
const intervalSpec = interval > -1 ? `repeatedly, with ${interval}-second intervals ` : '';
|
|
37
|
-
console.log(`Watching started ${intervalSpec}(${nowString()})\n`);
|
|
38
|
-
// Start the checking.
|
|
39
|
-
if (isDirWatch) {
|
|
40
|
-
await checkDirJob(interval);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
checkNetJob(0, interval);
|
|
44
|
-
}
|
|
45
|
-
};
|