Skip to content

Instantly share code, notes, and snippets.

@jswartwood
Created January 6, 2012 19:36
Show Gist options
  • Save jswartwood/1572043 to your computer and use it in GitHub Desktop.
Save jswartwood/1572043 to your computer and use it in GitHub Desktop.
Example use-case for and1
var fs = require("fs")
, andOne = require(process.env.AEO_BIN + "/lib/andOne.js")
;
// ==============
// Define Actions
// ==============
module.exports = {
// Set the build infomation as the SVN CWD
setActive: function() {
andOne
.queue(function( one ) {
// Start setup before func
console.log("start setting...");
// Start something async
setTimeout(function() {
one.resolve("set");
}, 3000);
})
.then(function( action ) {
// This happens when done
console.log(action + " done");
})
;
}
// Test the SVN CWD against the latest recorded build; display the results
, testActive: function() {
andOne
.queue(function( one ) {
// Execute some setup stuff
console.log("start testing...");
// Start something async
setTimeout(function() {
one.resolve("test");
}, 4000);
})
.then(function() {
// This happens when done
console.log("test done");
})
;
}
// Display the lastest build information
, getActive: function() {
andOne.queue().then(function() {
// This happens when done
console.log("get done");
});
}
};
#!/usr/bin/env node
var optimist = require("optimist")(process.argv)
, build = require(process.env.AEO_BIN + "/lib/local-build-tools.js")
;
optimist
.usage("\nUsage: localbuild [options]\n\nManage which local svn branch is the latest local build.")
.alias({
"h": "help"
, "s": "set"
, "t": "test"
, "i": "info"
, "f": "func"
})
.boolean([ "h", "s", "t", "i" ])
.describe({
"h": "Display this help information"
, "s": "Sets the current SVN branch (@rev - in the current working directory) as the latest build"
, "t": "Test the current SVN branch (@rev - in the current working directory) against the latest build"
, "i": "Run both '--get' and '--test' and display an info summary"
})
;
var argv = optimist.argv;
if (argv.h) return console.log(optimist.help());
if (argv.s) build.setActive();
if (argv.t || argv.i) build.testActive();
if (!argv.t || argv.i) build.getActive();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment