Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/nodegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ function createCommonFiles(templateDirectory, data) {
console.error(error);
}
}
try {
fs.mkdirSync(path.join(data.dst, data.module, 'examples'));
} catch (error) {
if (error.code !== 'EEXIST') {
console.error(error);
}
}
try {
fs.mkdirSync(path.join(data.dst, data.module, 'test'));
} catch (error) {
Expand All @@ -119,8 +126,6 @@ function createCommonFiles(templateDirectory, data) {
console.error(error);
}
}


}

function runNpmPack(data) {
Expand Down Expand Up @@ -253,6 +258,11 @@ function function2node(data, options) {
var htmlSourceCode = mustache.render(htmlTemplate, params);
fs.writeFileSync(path.join(data.dst, data.module, 'node.html'), htmlSourceCode);

// Create flow.json
var flowTemplate = fs.readFileSync(path.join(__dirname, '../templates/function/examples/flow.json.mustache'), 'utf-8');
var flowSourceCode = mustache.render(flowTemplate, params);
fs.writeFileSync(path.join(data.dst, data.module, 'examples/flow.json'), flowSourceCode);

// Create node_spec.js
var nodeSpecTemplate = fs.readFileSync(path.join(__dirname, '../templates/function/test/node_spec.js.mustache'), 'utf-8');
var nodeSpecSourceCode = mustache.render(nodeSpecTemplate, params);
Expand Down
60 changes: 60 additions & 0 deletions templates/function/examples/flow.json.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[
{
"id": "786d9ce1.c1c3a4",
"type": "inject",
"z": "7b8f4430.ec912c",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 0,
"y": 0,
"wires": [
[
"726f08b3.50bfd8"
]
]
},
{
"id": "726f08b3.50bfd8",
"type": "{{&nodeName}}",
"z": "7b8f4430.ec912c",
"name": "",
"x": 200,
"y": 0,
"wires": [
[
"82d40348.2d47b"
]
]
},
{
"id": "82d40348.2d47b",
"type": "debug",
"z": "7b8f4430.ec912c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 400,
"y": 0,
"wires": []
}
]