@lowdefy/node-utils 3.23.3 → 4.0.0-alpha.11
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 +18 -27
- package/dist/{createGetSecretsFromEnv.js → copyDirectory.js} +5 -21
- package/dist/getConfigFromEnv.js +24 -0
- package/dist/getFileExtension.js +14 -29
- package/dist/getSecretsFromEnv.js +25 -0
- package/dist/index.js +23 -57
- package/dist/readFile.js +30 -49
- package/dist/spawnProcess.js +48 -0
- package/dist/writeFile.js +33 -57
- package/package.json +17 -14
package/dist/cleanDirectory.js
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function cleanDirectory(
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function _cleanDirectory() {
|
|
21
|
-
_cleanDirectory = _asyncToGenerator(function* (dirPath) {
|
|
22
|
-
yield new Promise(resolve => (0, _rimraf.default)(dirPath, resolve));
|
|
23
|
-
});
|
|
24
|
-
return _cleanDirectory.apply(this, arguments);
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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 fsExtra from 'fs-extra';
|
|
16
|
+
async function cleanDirectory(dirPath) {
|
|
17
|
+
await fsExtra.emptyDir(dirPath);
|
|
25
18
|
}
|
|
26
|
-
|
|
27
|
-
var _default = cleanDirectory;
|
|
28
|
-
exports.default = _default;
|
|
19
|
+
export default cleanDirectory;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
1
|
/*
|
|
9
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
10
3
|
|
|
11
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
5
|
you may not use this file except in compliance with the License.
|
|
@@ -19,17 +12,8 @@ exports.default = void 0;
|
|
|
19
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
13
|
See the License for the specific language governing permissions and
|
|
21
14
|
limitations under the License.
|
|
22
|
-
*/
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
Object.keys(process.env).forEach(key => {
|
|
26
|
-
if (key.startsWith('LOWDEFY_SECRET_')) {
|
|
27
|
-
secrets[key.replace('LOWDEFY_SECRET_', '')] = process.env[key];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.freeze(secrets);
|
|
31
|
-
return () => secrets;
|
|
15
|
+
*/ import fsExtra from 'fs-extra';
|
|
16
|
+
async function copyDirectory(dirPathFrom, dirPathTo, options) {
|
|
17
|
+
await fsExtra.copy(dirPathFrom, dirPathTo, options);
|
|
32
18
|
}
|
|
33
|
-
|
|
34
|
-
var _default = createGetSecretsFromEnv;
|
|
35
|
-
exports.default = _default;
|
|
19
|
+
export default copyDirectory;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ function getConfigFromEnv() {
|
|
16
|
+
return {
|
|
17
|
+
buildDirectory: process.env.LOWDEFY_SERVER_BUILD_DIRECTORY,
|
|
18
|
+
logLevel: process.env.LOWDEFY_SERVER_LOG_LEVEL,
|
|
19
|
+
publicDirectory: process.env.LOWDEFY_SERVER_PUBLIC_DIRECTORY,
|
|
20
|
+
port: process.env.LOWDEFY_SERVER_PORT && parseInt(process.env.LOWDEFY_SERVER_PORT),
|
|
21
|
+
basePath: process.env.LOWDEFY_BASE_PATH
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export default getConfigFromEnv;
|
package/dist/getFileExtension.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getFileSubExtension = getFileSubExtension;
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
|
|
9
1
|
/*
|
|
10
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
11
3
|
|
|
12
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
5
|
you may not use this file except in compliance with the License.
|
|
@@ -20,26 +12,19 @@ exports.default = void 0;
|
|
|
20
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
13
|
See the License for the specific language governing permissions and
|
|
22
14
|
limitations under the License.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return arr[arr.length - 1];
|
|
15
|
+
*/ function getFileExtension(filePath) {
|
|
16
|
+
const arr = filePath.split('.');
|
|
17
|
+
if (arr.length === 1) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return arr[arr.length - 1];
|
|
32
21
|
}
|
|
33
|
-
|
|
34
22
|
function getFileSubExtension(path) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return arr[arr.length - 2];
|
|
23
|
+
const arr = path.split('.');
|
|
24
|
+
if (arr.length < 3) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return arr[arr.length - 2];
|
|
42
28
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
exports.default = _default;
|
|
29
|
+
export { getFileSubExtension };
|
|
30
|
+
export default getFileExtension;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
+
*/ function getSecretsFromEnv() {
|
|
16
|
+
const secrets = {};
|
|
17
|
+
Object.keys(process.env).forEach((key)=>{
|
|
18
|
+
if (key.startsWith('LOWDEFY_SECRET_')) {
|
|
19
|
+
secrets[key.replace('LOWDEFY_SECRET_', '')] = process.env[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
Object.freeze(secrets);
|
|
23
|
+
return secrets;
|
|
24
|
+
}
|
|
25
|
+
export default getSecretsFromEnv;
|
package/dist/index.js
CHANGED
|
@@ -1,57 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
Object.defineProperty(exports, "getFileSubExtension", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function get() {
|
|
27
|
-
return _getFileExtension.getFileSubExtension;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "readFile", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function get() {
|
|
33
|
-
return _readFile.default;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "writeFile", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function get() {
|
|
39
|
-
return _writeFile.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
var _cleanDirectory = _interopRequireDefault(require("./cleanDirectory"));
|
|
44
|
-
|
|
45
|
-
var _createGetSecretsFromEnv = _interopRequireDefault(require("./createGetSecretsFromEnv"));
|
|
46
|
-
|
|
47
|
-
var _getFileExtension = _interopRequireWildcard(require("./getFileExtension"));
|
|
48
|
-
|
|
49
|
-
var _readFile = _interopRequireDefault(require("./readFile"));
|
|
50
|
-
|
|
51
|
-
var _writeFile = _interopRequireDefault(require("./writeFile"));
|
|
52
|
-
|
|
53
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
54
|
-
|
|
55
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
56
|
-
|
|
57
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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 cleanDirectory from './cleanDirectory.js';
|
|
16
|
+
import copyDirectory from './copyDirectory.js';
|
|
17
|
+
import getConfigFromEnv from './getConfigFromEnv.js';
|
|
18
|
+
import getFileExtension, { getFileSubExtension } from './getFileExtension.js';
|
|
19
|
+
import getSecretsFromEnv from './getSecretsFromEnv.js';
|
|
20
|
+
import spawnProcess from './spawnProcess.js';
|
|
21
|
+
import readFile from './readFile.js';
|
|
22
|
+
import writeFile from './writeFile.js';
|
|
23
|
+
export { cleanDirectory, copyDirectory, getConfigFromEnv, getFileExtension, getFileSubExtension, getSecretsFromEnv, spawnProcess, readFile, writeFile };
|
package/dist/readFile.js
CHANGED
|
@@ -1,54 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function readFile(_x) {
|
|
25
|
-
return _readFile.apply(this, arguments);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function _readFile() {
|
|
29
|
-
_readFile = _asyncToGenerator(function* (filePath) {
|
|
30
|
-
if (!_helpers.type.isString(filePath)) {
|
|
31
|
-
throw new Error("Could not read file, file path should be a string, received ".concat(JSON.stringify(filePath), "."));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (filePath !== _path.default.resolve(filePath)) {
|
|
35
|
-
throw new Error("Could not read file, file path was not resolved, received ".concat(JSON.stringify(filePath), "."));
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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 fs from 'fs';
|
|
16
|
+
import path from 'path';
|
|
17
|
+
import { promisify } from 'util';
|
|
18
|
+
import { type } from '@lowdefy/helpers';
|
|
19
|
+
const readFilePromise = promisify(fs.readFile);
|
|
20
|
+
async function readFile(filePath) {
|
|
21
|
+
if (!type.isString(filePath)) {
|
|
22
|
+
throw new Error(`Could not read file, file path should be a string, received ${JSON.stringify(filePath)}.`);
|
|
36
23
|
}
|
|
37
|
-
|
|
38
24
|
try {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
25
|
+
// By specifying encoding, readFile returns a string instead of a buffer.
|
|
26
|
+
const file = await readFilePromise(path.resolve(filePath), 'utf8');
|
|
27
|
+
return file;
|
|
42
28
|
} catch (error) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
throw error;
|
|
29
|
+
if (error.code === 'ENOENT' || error.code === 'EISDIR') {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
throw error;
|
|
48
33
|
}
|
|
49
|
-
});
|
|
50
|
-
return _readFile.apply(this, arguments);
|
|
51
34
|
}
|
|
52
|
-
|
|
53
|
-
var _default = readFile;
|
|
54
|
-
exports.default = _default;
|
|
35
|
+
export default readFile;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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
|
@@ -1,62 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function writeFile(_x) {
|
|
26
|
-
return _writeFile.apply(this, arguments);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function _writeFile() {
|
|
30
|
-
_writeFile = _asyncToGenerator(function* (_ref) {
|
|
31
|
-
var {
|
|
32
|
-
filePath,
|
|
33
|
-
content
|
|
34
|
-
} = _ref;
|
|
35
|
-
|
|
36
|
-
if (!_helpers.type.isString(filePath)) {
|
|
37
|
-
throw new Error("Could not write file, file path should be a string, received ".concat(JSON.stringify(filePath), "."));
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 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 fs from 'fs';
|
|
16
|
+
import path from 'path';
|
|
17
|
+
import { promisify } from 'util';
|
|
18
|
+
import { type } from '@lowdefy/helpers';
|
|
19
|
+
const mkdirPromise = promisify(fs.mkdir);
|
|
20
|
+
const writeFilePromise = promisify(fs.writeFile);
|
|
21
|
+
async function writeFile(filePath, content) {
|
|
22
|
+
if (!type.isString(filePath)) {
|
|
23
|
+
throw new Error(`Could not write file, file path should be a string, received ${JSON.stringify(filePath)}.`);
|
|
38
24
|
}
|
|
39
|
-
|
|
40
|
-
if (filePath !== _path.default.resolve(filePath)) {
|
|
41
|
-
throw new Error("Could not write file, file path was not resolved, received ".concat(JSON.stringify(filePath), "."));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
25
|
try {
|
|
45
|
-
|
|
26
|
+
await writeFilePromise(path.resolve(filePath), content);
|
|
46
27
|
} catch (error) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
throw error;
|
|
28
|
+
if (error.code === 'ENOENT') {
|
|
29
|
+
await mkdirPromise(path.dirname(filePath), {
|
|
30
|
+
recursive: true
|
|
31
|
+
});
|
|
32
|
+
await writeFilePromise(filePath, content);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
56
36
|
}
|
|
57
|
-
});
|
|
58
|
-
return _writeFile.apply(this, arguments);
|
|
59
37
|
}
|
|
60
|
-
|
|
61
|
-
var _default = writeFile;
|
|
62
|
-
exports.default = _default;
|
|
38
|
+
export default writeFile;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/node-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.11",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
@@ -25,30 +25,33 @@
|
|
|
25
25
|
"type": "git",
|
|
26
26
|
"url": "https://github.com/lowdefy/lowdefy.git"
|
|
27
27
|
},
|
|
28
|
-
"
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": "./dist/index.js",
|
|
31
|
+
"./*": "./dist/*"
|
|
32
|
+
},
|
|
29
33
|
"files": [
|
|
30
34
|
"dist/*"
|
|
31
35
|
],
|
|
32
36
|
"scripts": {
|
|
33
|
-
"build": "
|
|
37
|
+
"build": "yarn swc",
|
|
34
38
|
"clean": "rm -rf dist",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
39
|
+
"prepare": "yarn build",
|
|
40
|
+
"swc": "swc src --out-dir dist --config-file ../../../.swcrc --delete-dir-on-start",
|
|
41
|
+
"test": "jest --coverage"
|
|
37
42
|
},
|
|
38
43
|
"dependencies": {
|
|
39
|
-
"@lowdefy/helpers": "
|
|
40
|
-
"
|
|
44
|
+
"@lowdefy/helpers": "4.0.0-alpha.11",
|
|
45
|
+
"fs-extra": "10.0.0"
|
|
41
46
|
},
|
|
42
47
|
"devDependencies": {
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"
|
|
47
|
-
"jest": "26.6.3",
|
|
48
|
-
"jest-diff": "26.6.2"
|
|
48
|
+
"@swc/cli": "0.1.55",
|
|
49
|
+
"@swc/core": "1.2.135",
|
|
50
|
+
"@swc/jest": "0.2.17",
|
|
51
|
+
"jest": "27.5.1"
|
|
49
52
|
},
|
|
50
53
|
"publishConfig": {
|
|
51
54
|
"access": "public"
|
|
52
55
|
},
|
|
53
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "810fb2d8cb9ee8b0586b55fbbf26a5a5a0da3b2a"
|
|
54
57
|
}
|