Skip to content

Commit

Permalink
Inherit directory context to subgraphs
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Jan 26, 2013
1 parent c819740 commit a3269ae
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -6,6 +6,7 @@ NoFlo ChangeLog
NoFlo internals:

* The NoFlo `.fbp` parser now [guards against recursion](https://github.com/bergie/noflo/pull/57) on inline subgraphs
* NoFlo subgraphs now inherit the directory context for component loading from the NoFlo process that loaded them

New component libraries:

Expand Down
2 changes: 2 additions & 0 deletions src/components/Graph.coffee
Expand Up @@ -4,6 +4,7 @@ class Graph extends noflo.Component
constructor: ->
@network = null
@ready = true
@baseDir = null

@inPorts =
graph: new noflo.Port()
Expand All @@ -21,6 +22,7 @@ class Graph extends noflo.Component
graph = "#{process.cwd()}/#{graph}"

graph = noflo.graph.loadFile graph, (instance) =>
instance.baseDir = @baseDir
@createNetwork instance

createNetwork: (graph) ->
Expand Down
1 change: 1 addition & 0 deletions src/lib/ComponentLoader.coffee
Expand Up @@ -87,6 +87,7 @@ class ComponentLoader
graphImplementation = require @components['Graph']
graphSocket = internalSocket.createSocket()
graph = graphImplementation.getComponent()
graph.baseDir = @baseDir
graph.inPorts.graph.attach graphSocket
graphSocket.send @components[name]
graphSocket.disconnect()
Expand Down
3 changes: 2 additions & 1 deletion src/lib/Network.coffee
Expand Up @@ -28,6 +28,7 @@ class Network extends events.EventEmitter
@connections = []
@initials = []
@graph = graph
@baseDir = graph.baseDir or process.cwd()

# As most NoFlo networks are long-running processes, the
# network coordinator marks down the start-up time. This
Expand All @@ -49,7 +50,7 @@ class Network extends events.EventEmitter
@addEdge edge
@graph.on 'removeEdge', (edge) =>
@removeEdge edge
@loader = new componentLoader.ComponentLoader process.cwd()
@loader = new componentLoader.ComponentLoader @baseDir

# The uptime of the network is the current time minus the start-up
# time, in seconds.
Expand Down

0 comments on commit a3269ae

Please sign in to comment.