Skip to content

Commit

Permalink
Merge pull request #134 from kazuhitoyokoi/master-errorhandling4subflow
Browse files Browse the repository at this point in the history
Add error handling for no module property in subflow
  • Loading branch information
kazuhitoyokoi authored Jun 21, 2022
2 parents 5b719eb + f5bdc79 commit c2ddb74
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions bin/node-red-nodegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ function skipBom(body) {

function isSubflowDefinition(data) {
return data.find((item) => {
return ((item.type === "subflow") &&
(item.hasOwnProperty("meta")));
return item.type === "subflow";
});
}

Expand Down Expand Up @@ -156,7 +155,6 @@ if (argv.help || argv.h) {
promise.then(function (result) {
console.log('Success: ' + result);
}).catch(function (error) {
console.log('Error: ' + error);
console.log(error.stack);
});
}
Expand Down
6 changes: 3 additions & 3 deletions lib/subflow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const crypt = require("crypto-js");

const TEMPLATE_DIR = path.join(__dirname,'../../templates/subflow');


// Extract Subflow definition from JSON data
function getSubflowDef(flow) {
const newFlow = [];
Expand All @@ -24,10 +23,12 @@ function getSubflowDef(flow) {
newFlow.push(item);
}
});
if (sf == null) {
throw new Error("No module properties in subflow");
}
return [sf, newFlow];
}


// get flow encoding method
function getEncoder(encoding) {
if (encoding === "AES") {
Expand Down Expand Up @@ -58,7 +59,6 @@ function createJSON(dstPath, flow, encoding, key) {
fs.writeFileSync(dstPath, data);
}


module.exports = async function(data, options) {
"use strict";

Expand Down

0 comments on commit c2ddb74

Please sign in to comment.