This node selects a group of files based on a pattern using the "glob" npm package.
| Input | Type |
|---|---|
| pattern | Text |
| Output | Type |
|---|---|
| files | [File] |
| -- Used for the palette | |
| node { | |
| -- this Name will be matched against the Type in the Graph | |
| name = "Glob" | |
| -- Name of the Input/Output followed by a valid type signature | |
| inputs { | |
| pattern = { type = "Text", default = "*.txt" } | |
| } | |
| outputs { | |
| files = "[File]" -- Array of files, uses haskell syntax for types | |
| } | |
| } | |
| valid contexts [ | |
| -- Provides the "JS Primitive" node, the File type, ... | |
| node-js | |
| node-build-system | |
| ] | |
| npm dependencies [ | |
| "glob" | |
| ] | |
| -- Internal graph, the node whole node is threated as a group (by linking, not in reality) | |
| graph { | |
| nodes [ | |
| { | |
| type = "JS Primitive" | |
| gid = 49375234 | |
| -- needs a fragment and the parameters to the function | |
| inputs { | |
| -- the code: | |
| fragment = { | |
| type = "Fragment" | |
| fid = "glob.fragment.js" | |
| -- The code: | |
| -- function (pattern) { const glob = require('glob'); ... fs ... return glob.sync(...); } | |
| } | |
| -- function args: | |
| pattern = { | |
| type = "Text" | |
| } | |
| } | |
| outputs { | |
| files = { | |
| type = "[File]" | |
| } | |
| } | |
| } | |
| ] | |
| -- Connections that starts from a dollar label ("$Pattern") get connected to the group inputs | |
| -- Connections that ends in a dollar label ("$Files") get connected to the group outputs | |
| connections [ | |
| { from = $pattern, to = [ 49375234 pattern ] } | |
| { from = [ 49375234 files ], to = $files } | |
| ] | |
| } |