                 name: payload.name
                 language: "c++"
                 code: source
-
             connection.send
                 protocol: "component"
                 command: "source"
                 payload: r
-
-            return
-
+            return
     else
         console.log "Unknown NoFlo UI command on 'component' protocol:", command, payload
     return

        a.push
            id: name
            type: "all"

    a

connectionsWithoutEdge = (connections, findConn) ->
    edgeEq (a, b) ->
        JSON.stringify a == JSON.stringify b
    newList = []
    connections.forEach (conn) ->
        if conn.src and edgeEq conn.src findConn.src and edgeEq conn.tgt, findConn.tgt
            # Connection
        else if conn.data and edgeEq conn.tgt, findConn.tgt
            # IIP

    outputDir = path.dirname(outputBase)
    fs.mkdirSync outputDir    unless fs.existsSync(outputDir)
    loadFile inputFile, (err, def) ->
        throw err if err
        
        # TODO: allow to generate just one of these
        fs.writeFile outputBase + ".json", JSON.stringify(def), (err) ->
            throw err if err
            return
        data = commandstream.cmdStreamFromGraph(componentLib, def)
        fs.writeFile outputBase + ".fbcs", data, (err) ->
            throw err if err
            return
        fs.writeFile outputBase + ".h", generate.cmdStreamToCDefinition(data, target), (err) ->
            throw err if err
            return
        fs.writeFile outputFile, generate.cmdStreamToCDefinition(data, target) + "\n" + "#define MICROFLO_EMBED_GRAPH\n" + "#include \"microflo.h\"" + "\n#include \"main.hpp\"", (err) ->
            throw err if err
            return


# TODO: Use noflo.graph.loadFile() instead?
loadFile = (filename, callback) ->
    fs.readFile filename, { encoding: "utf8" }, (err, data) ->
        console.log filename
        console.log data
        return callback err if err
        def = null
        if (path.extname filename) is ".fbp"
            def = fbp.parse data
        else
            def = JSON.parse data
        return callback null, def


# TODO: allow port types to be declared in component metadata,
