refactor: Format nodes-base package (A-F) (#3800)

* 🔨 prettier formated nodes - A

* 🔨 prettier formated nodes - B

*  prettier formated nodes - C

*  prettier formated nodes - D

*  prettier formated nodes - E-F

* 🎨 Adjust nodes-base formatting command (#3805)

* Format additional files in nodes A-F (#3811)

*  fixes

* 🎨 Add Mindee to ignored dirs

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
Michael Kret
2022-08-01 23:47:55 +03:00
committed by GitHub
parent 2c17e6f3ca
commit 0ecbb4a19d
411 changed files with 12906 additions and 20148 deletions

View File

@@ -60,7 +60,7 @@ return item;`,
let item: INodeExecutionData;
const cleanupData = (inputData: IDataObject): IDataObject => {
Object.keys(inputData).map(key => {
Object.keys(inputData).map((key) => {
if (inputData[key] !== null && typeof inputData[key] === 'object') {
if (inputData[key]!.constructor.name === 'Object') {
// Is regular node.js object so check its data
@@ -102,7 +102,7 @@ return item;`,
const mode = this.getMode();
const options = {
console: (mode === 'manual') ? 'redirect' : 'inherit',
console: mode === 'manual' ? 'redirect' : 'inherit',
sandbox,
require: {
external: false as boolean | { modules: string[] },
@@ -115,7 +115,9 @@ return item;`,
}
if (process.env.NODE_FUNCTION_ALLOW_EXTERNAL) {
options.require.external = { modules: process.env.NODE_FUNCTION_ALLOW_EXTERNAL.split(',') };
options.require.external = {
modules: process.env.NODE_FUNCTION_ALLOW_EXTERNAL.split(','),
};
}
const vm = new NodeVM(options);
@@ -130,17 +132,22 @@ return item;`,
let jsonData: IDataObject;
try {
// Execute the function code
jsonData = await vm.run(`module.exports = async function() {${functionCode}\n}()`, __dirname);
jsonData = await vm.run(
`module.exports = async function() {${functionCode}\n}()`,
__dirname,
);
} catch (error) {
if (this.continueOnFail()) {
returnData.push({json:{ error: error.message }});
returnData.push({ json: { error: error.message } });
continue;
} else {
// Try to find the line number which contains the error and attach to error message
const stackLines = error.stack.split('\n');
if (stackLines.length > 0) {
stackLines.shift();
const lineParts = stackLines.find((line: string) => line.includes('FunctionItem')).split(':');
const lineParts = stackLines
.find((line: string) => line.includes('FunctionItem'))
.split(':');
if (lineParts.length > 2) {
const lineNumber = lineParts.splice(-2, 1);
if (!isNaN(lineNumber)) {
@@ -158,7 +165,10 @@ return item;`,
// Do very basic validation of the data
if (jsonData === undefined) {
throw new NodeOperationError(this.getNode(), 'No data got returned. Always an object has to be returned!');
throw new NodeOperationError(
this.getNode(),
'No data got returned. Always an object has to be returned!',
);
}
const returnItem: INodeExecutionData = {