@lowdefy/node-utils 4.0.0-alpha.5 → 4.0.0-alpha.6
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/getSecretsFromEnv.js +1 -2
- package/dist/index.js +2 -1
- package/dist/spawnProcess.js +48 -0
- package/dist/writeFile.js +1 -4
- package/package.json +6 -6
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ function getSecretsFromEnv() {
|
|
16
|
-
const secrets = {
|
|
17
|
-
};
|
|
16
|
+
const secrets = {};
|
|
18
17
|
Object.keys(process.env).forEach((key)=>{
|
|
19
18
|
if (key.startsWith('LOWDEFY_SECRET_')) {
|
|
20
19
|
secrets[key.replace('LOWDEFY_SECRET_', '')] = process.env[key];
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import getConfigFromEnv from './getConfigFromEnv.js';
|
|
17
17
|
import getFileExtension, { getFileSubExtension } from './getFileExtension.js';
|
|
18
18
|
import getSecretsFromEnv from './getSecretsFromEnv.js';
|
|
19
|
+
import spawnProcess from './spawnProcess.js';
|
|
19
20
|
import readFile from './readFile.js';
|
|
20
21
|
import writeFile from './writeFile.js';
|
|
21
|
-
export { cleanDirectory, getConfigFromEnv, getFileExtension, getFileSubExtension, getSecretsFromEnv, readFile, writeFile };
|
|
22
|
+
export { cleanDirectory, getConfigFromEnv, getFileExtension, getFileSubExtension, getSecretsFromEnv, spawnProcess, readFile, writeFile };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2021 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { spawn } from 'child_process';
|
|
16
|
+
async function spawnProcess({ logger , command , args , processOptions , silent }) {
|
|
17
|
+
return new Promise((resolve, reject)=>{
|
|
18
|
+
const process = spawn(command, args, processOptions);
|
|
19
|
+
process.stdout.on('data', (data)=>{
|
|
20
|
+
if (!silent) {
|
|
21
|
+
data.toString('utf8').split('\n').forEach((line)=>{
|
|
22
|
+
if (line) {
|
|
23
|
+
logger.log(line);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
process.stderr.on('data', (data)=>{
|
|
29
|
+
if (!silent) {
|
|
30
|
+
data.toString('utf8').split('\n').forEach((line)=>{
|
|
31
|
+
if (line) {
|
|
32
|
+
logger.warn(line);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
process.on('error', (error)=>{
|
|
38
|
+
reject(error);
|
|
39
|
+
});
|
|
40
|
+
process.on('exit', (code)=>{
|
|
41
|
+
if (code !== 0) {
|
|
42
|
+
reject(new Error(`${command} exited with code ${code}`));
|
|
43
|
+
}
|
|
44
|
+
resolve();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export default spawnProcess;
|
package/dist/writeFile.js
CHANGED
|
@@ -22,11 +22,8 @@ async function writeFile({ filePath , content }) {
|
|
|
22
22
|
if (!type.isString(filePath)) {
|
|
23
23
|
throw new Error(`Could not write file, file path should be a string, received ${JSON.stringify(filePath)}.`);
|
|
24
24
|
}
|
|
25
|
-
if (filePath !== path.resolve(filePath)) {
|
|
26
|
-
throw new Error(`Could not write file, file path was not resolved, received ${JSON.stringify(filePath)}.`);
|
|
27
|
-
}
|
|
28
25
|
try {
|
|
29
|
-
await writeFilePromise(filePath, content);
|
|
26
|
+
await writeFilePromise(path.resolve(filePath), content);
|
|
30
27
|
} catch (error) {
|
|
31
28
|
if (error.code === 'ENOENT') {
|
|
32
29
|
await mkdirPromise(path.dirname(filePath), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/node-utils",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.6",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
"test": "jest --coverage"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
44
|
+
"@lowdefy/helpers": "4.0.0-alpha.6",
|
|
45
45
|
"rimraf": "3.0.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@swc/cli": "0.1.
|
|
49
|
-
"@swc/core": "1.2.
|
|
50
|
-
"@swc/jest": "0.2.
|
|
48
|
+
"@swc/cli": "0.1.55",
|
|
49
|
+
"@swc/core": "1.2.130",
|
|
50
|
+
"@swc/jest": "0.2.17",
|
|
51
51
|
"jest": "27.3.1"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "2530e31af795b6a3c75ac8f72c8dbe0ab5d1251b"
|
|
57
57
|
}
|