Skip to content

Commit

Permalink
Changed the update procedure to recursively checkout and generate unt…
Browse files Browse the repository at this point in the history
…il no additional nodes are being added to the graph
  • Loading branch information
Eric Cornelius authored and Eric Cornelius committed Aug 30, 2013
1 parent deaf944 commit 075b1e2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
34 changes: 32 additions & 2 deletions lib/actions.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -305,18 +310,21 @@ 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);
});
});
}

function generic(name, cb) {
cb = cb || function() {};

try {

console.log('Loading command graph from'.cyan, graph_path.yellow);
var graph = read_graph(graph_path);

Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/registry/processors/git.js
Expand Up @@ -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)],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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",
Expand Down

0 comments on commit 075b1e2

Please sign in to comment.