Skip to content

Instantly share code, notes, and snippets.

@aziis98
Last active July 13, 2018 01:22
Show Gist options
  • Select an option

  • Save aziis98/53cc6dccc0266a1c9fe1efac1f932f18 to your computer and use it in GitHub Desktop.

Select an option

Save aziis98/53cc6dccc0266a1c9fe1efac1f932f18 to your computer and use it in GitHub Desktop.

Glob

This node selects a group of files based on a pattern using the "glob" npm package.

Definition

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 }
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment