From 075b1e252a9a9cf0573feadeb6a8bfc2778bebe9 Mon Sep 17 00:00:00 2001 From: Eric Cornelius Date: Fri, 30 Aug 2013 17:44:29 -0400 Subject: [PATCH] Changed the update procedure to recursively checkout and generate until no additional nodes are being added to the graph --- lib/actions.js | 34 ++++++++++++++++++++++++++++++++-- lib/registry/processors/git.js | 3 +++ package.json | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lib/actions.js b/lib/actions.js index 939a229..dacddef 100755 --- a/lib/actions.js +++ b/lib/actions.js @@ -268,7 +268,12 @@ function render_graph(g, action) { } function get_nodes() { - return new registry(nodes_path).nodes; + try { + return new registry(nodes_path).nodes; + } + catch(err) { + return []; + } } function register(cb) { @@ -305,11 +310,12 @@ function generate(cb) { console.log('Done with node:'.cyan, node.id.yellow); } }, - function() { + function(err) { var cmd_graph = new DependencyGraph(graph.generated); console.log('Writing command graph to'.cyan, graph_path.yellow); write_graph(cmd_graph, graph_path); console.log('Done'.cyan); + cb(err); }); }); } @@ -317,6 +323,8 @@ function generate(cb) { function generic(name, cb) { cb = cb || function() {}; + try { + console.log('Loading command graph from'.cyan, graph_path.yellow); var graph = read_graph(graph_path); @@ -328,7 +336,14 @@ function generic(name, cb) { }, function(err) { console.log('Done'.cyan); + cb(err); }); + + } + catch(err) { + console.log('Unable to read graph'.red); + cb(); + } } function posh(action) { @@ -446,6 +461,21 @@ function posh(action) { console.log('Done'.cyan); }); break; + case 'update': + var count_call = function(cb) { + cb(null, get_nodes().length); + }; + var update_call = async.apply(generic, 'update'); + + async.series( + [count_call, update_call, generate, count_call], + function(err, results) { + if (results[0] !== results[3]) { + var proc = spawn('posh', ['update'], {stdio: 'inherit'}); + } + } + ); + break; default: generic(action); } diff --git a/lib/registry/processors/git.js b/lib/registry/processors/git.js index beffa6e..e97de97 100644 --- a/lib/registry/processors/git.js +++ b/lib/registry/processors/git.js @@ -82,6 +82,9 @@ function generate(graph, node, cb) { }); } else { + if (config.tag) + return cb(); + graph.generated.push({ id: node.id + '.git_pull', cmds: [create_git_pull_command(config)], diff --git a/package.json b/package.json index c4e8eff..ad531c3 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "node": "0.8.*" }, "dependencies": { - "async": "0.2.6", + "async": "0.2.9", "glob": "3.1.21", "shelljs": "0.1.2", "clone": "0.1.5",