Skip to content

Commit d914f7e

Browse files
Merge pull request #111 from kazuhitoyokoi/master-addexampleflow
Add example flow to function node template
2 parents 121e22e + ad190e4 commit d914f7e

File tree

2 files changed

+72
-2
lines changed

2 files changed

+72
-2
lines changed

lib/nodegen.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ function createCommonFiles(templateDirectory, data) {
104104
console.error(error);
105105
}
106106
}
107+
try {
108+
fs.mkdirSync(path.join(data.dst, data.module, 'examples'));
109+
} catch (error) {
110+
if (error.code !== 'EEXIST') {
111+
console.error(error);
112+
}
113+
}
107114
try {
108115
fs.mkdirSync(path.join(data.dst, data.module, 'test'));
109116
} catch (error) {
@@ -119,8 +126,6 @@ function createCommonFiles(templateDirectory, data) {
119126
console.error(error);
120127
}
121128
}
122-
123-
124129
}
125130

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

261+
// Create flow.json
262+
var flowTemplate = fs.readFileSync(path.join(__dirname, '../templates/function/examples/flow.json.mustache'), 'utf-8');
263+
var flowSourceCode = mustache.render(flowTemplate, params);
264+
fs.writeFileSync(path.join(data.dst, data.module, 'examples/flow.json'), flowSourceCode);
265+
256266
// Create node_spec.js
257267
var nodeSpecTemplate = fs.readFileSync(path.join(__dirname, '../templates/function/test/node_spec.js.mustache'), 'utf-8');
258268
var nodeSpecSourceCode = mustache.render(nodeSpecTemplate, params);
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
[
2+
{
3+
"id": "786d9ce1.c1c3a4",
4+
"type": "inject",
5+
"z": "7b8f4430.ec912c",
6+
"name": "",
7+
"props": [
8+
{
9+
"p": "payload"
10+
},
11+
{
12+
"p": "topic",
13+
"vt": "str"
14+
}
15+
],
16+
"repeat": "",
17+
"crontab": "",
18+
"once": false,
19+
"onceDelay": 0.1,
20+
"topic": "",
21+
"payload": "",
22+
"payloadType": "date",
23+
"x": 0,
24+
"y": 0,
25+
"wires": [
26+
[
27+
"726f08b3.50bfd8"
28+
]
29+
]
30+
},
31+
{
32+
"id": "726f08b3.50bfd8",
33+
"type": "{{&nodeName}}",
34+
"z": "7b8f4430.ec912c",
35+
"name": "",
36+
"x": 200,
37+
"y": 0,
38+
"wires": [
39+
[
40+
"82d40348.2d47b"
41+
]
42+
]
43+
},
44+
{
45+
"id": "82d40348.2d47b",
46+
"type": "debug",
47+
"z": "7b8f4430.ec912c",
48+
"name": "",
49+
"active": true,
50+
"tosidebar": true,
51+
"console": false,
52+
"tostatus": false,
53+
"complete": "false",
54+
"statusVal": "",
55+
"statusType": "auto",
56+
"x": 400,
57+
"y": 0,
58+
"wires": []
59+
}
60+
]

0 commit comments

Comments
 (0)