@quatrain/worker 1.1.26 → 1.1.28
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/lib/FileSystem.js +4 -3
- package/lib/Helpers.js +1 -1
- package/lib/Worker.js +22 -16
- package/package.json +1 -1
package/lib/FileSystem.js
CHANGED
|
@@ -63,6 +63,7 @@ class FileSystem {
|
|
|
63
63
|
}
|
|
64
64
|
static async downloadFile(url, filepath) {
|
|
65
65
|
try {
|
|
66
|
+
Worker_1.Worker.debug(`Downloading file at ${url} to ${filepath}`);
|
|
66
67
|
const writer = node_fs_1.default.createWriteStream(filepath);
|
|
67
68
|
const response = await axios_1.default.get(url, {
|
|
68
69
|
responseType: 'stream',
|
|
@@ -73,9 +74,9 @@ class FileSystem {
|
|
|
73
74
|
writer.on('error', reject);
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
|
-
catch (
|
|
77
|
-
|
|
78
|
-
throw
|
|
77
|
+
catch (err) {
|
|
78
|
+
Worker_1.Worker.error(`Download error: ${err.message}`);
|
|
79
|
+
throw err;
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
static safeString(name) {
|
package/lib/Helpers.js
CHANGED
package/lib/Worker.js
CHANGED
|
@@ -20,23 +20,29 @@ class Worker extends core_1.Core {
|
|
|
20
20
|
* @return Promise
|
|
21
21
|
*/
|
|
22
22
|
static execPromise = (command, args = [], cwd = process.cwd()) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
23
|
+
try {
|
|
24
|
+
Worker.info(`Executing command ${command} in ${cwd} with arguments:`);
|
|
25
|
+
args.forEach((arg) => console.log(`\t${arg}`));
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
const child = (0, child_process_1.spawn)(command, args, { cwd });
|
|
28
|
+
child.stdout.on('data', (data) => Worker.debug(data.toString()));
|
|
29
|
+
child.stderr.on('data', (data) => Worker.debug(data.toString()));
|
|
30
|
+
child.on('close', (code) => {
|
|
31
|
+
if (code !== 0) {
|
|
32
|
+
Worker.error(`Command execution failed with code: ${code}`);
|
|
33
|
+
reject(code);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
Worker.info(`Command execution completed with code: ${code}`);
|
|
37
|
+
resolve(undefined);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
38
40
|
});
|
|
39
|
-
}
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
Worker.error(err.message);
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
40
46
|
};
|
|
41
47
|
/**
|
|
42
48
|
* Push an event to the backend endpoint, if available
|