@lowdefy/node-utils 4.5.2 → 4.7.0
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/dist/cleanDirectory.js +1 -1
- package/dist/copyFileOrDirectory.js +1 -1
- package/dist/getFileExtension.js +1 -1
- package/dist/getSecretsFromEnv.js +1 -1
- package/dist/index.js +1 -1
- package/dist/readFile.js +2 -2
- package/dist/spawnProcess.js +20 -6
- package/dist/writeFile.js +2 -2
- package/package.json +3 -2
package/dist/cleanDirectory.js
CHANGED
package/dist/getFileExtension.js
CHANGED
package/dist/index.js
CHANGED
package/dist/readFile.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -19,7 +19,7 @@ import { type } from '@lowdefy/helpers';
|
|
|
19
19
|
const readFilePromise = promisify(fs.readFile);
|
|
20
20
|
async function readFile(filePath) {
|
|
21
21
|
if (!type.isString(filePath)) {
|
|
22
|
-
throw new Error(
|
|
22
|
+
throw new Error('Could not read file, file path should be a string.');
|
|
23
23
|
}
|
|
24
24
|
try {
|
|
25
25
|
// By specifying encoding, readFile returns a string instead of a buffer.
|
package/dist/spawnProcess.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,13 +14,23 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import { spawn } from 'child_process';
|
|
16
16
|
function createStdIOHandler({ lineHandler }) {
|
|
17
|
+
let buffer = '';
|
|
17
18
|
function handler(data) {
|
|
18
|
-
data.toString('utf8')
|
|
19
|
+
const text = buffer + data.toString('utf8');
|
|
20
|
+
const lines = text.split('\n');
|
|
21
|
+
buffer = lines.pop();
|
|
22
|
+
lines.forEach((line)=>{
|
|
19
23
|
if (line) {
|
|
20
24
|
lineHandler(line);
|
|
21
25
|
}
|
|
22
26
|
});
|
|
23
27
|
}
|
|
28
|
+
handler.flush = ()=>{
|
|
29
|
+
if (buffer) {
|
|
30
|
+
lineHandler(buffer);
|
|
31
|
+
buffer = '';
|
|
32
|
+
}
|
|
33
|
+
};
|
|
24
34
|
return handler;
|
|
25
35
|
}
|
|
26
36
|
function spawnProcess({ args, command, processOptions, returnProcess, stdErrLineHandler, stdOutLineHandler = ()=>{} }) {
|
|
@@ -28,12 +38,16 @@ function spawnProcess({ args, command, processOptions, returnProcess, stdErrLine
|
|
|
28
38
|
stdErrLineHandler = stdOutLineHandler;
|
|
29
39
|
}
|
|
30
40
|
const process = spawn(command, args, processOptions);
|
|
31
|
-
|
|
41
|
+
const stdOutHandler = createStdIOHandler({
|
|
32
42
|
lineHandler: stdOutLineHandler
|
|
33
|
-
})
|
|
34
|
-
|
|
43
|
+
});
|
|
44
|
+
const stdErrHandler = createStdIOHandler({
|
|
35
45
|
lineHandler: stdErrLineHandler
|
|
36
|
-
})
|
|
46
|
+
});
|
|
47
|
+
process.stdout.on('data', stdOutHandler);
|
|
48
|
+
process.stderr.on('data', stdErrHandler);
|
|
49
|
+
process.stdout.on('end', stdOutHandler.flush);
|
|
50
|
+
process.stderr.on('end', stdErrHandler.flush);
|
|
37
51
|
if (returnProcess) {
|
|
38
52
|
return process;
|
|
39
53
|
}
|
package/dist/writeFile.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -20,7 +20,7 @@ const mkdirPromise = promisify(fs.mkdir);
|
|
|
20
20
|
const writeFilePromise = promisify(fs.writeFile);
|
|
21
21
|
async function writeFile(filePath, content) {
|
|
22
22
|
if (!type.isString(filePath)) {
|
|
23
|
-
throw new Error(
|
|
23
|
+
throw new Error('Could not write file, file path should be a string.');
|
|
24
24
|
}
|
|
25
25
|
try {
|
|
26
26
|
await writeFilePromise(path.resolve(filePath), content);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/node-utils",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"dist/*"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@lowdefy/
|
|
37
|
+
"@lowdefy/errors": "4.7.0",
|
|
38
|
+
"@lowdefy/helpers": "4.7.0",
|
|
38
39
|
"fs-extra": "11.1.1"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|