combohandler
Advanced tools
Comparing version 0.3.3 to 0.3.4
@@ -19,17 +19,3 @@ #!/usr/bin/env node | ||
if (options.restart) { | ||
instance.restart(); | ||
} | ||
else if (options.shutdown) { | ||
instance.shutdown(); | ||
} | ||
else if (options.status) { | ||
instance.status(); | ||
} | ||
else if (options.stop) { | ||
instance.stop(); | ||
} | ||
else { | ||
instance.listen(); | ||
} | ||
args.invoke(instance); | ||
} else { | ||
@@ -36,0 +22,0 @@ // Legacy support |
Combo Handler History | ||
===================== | ||
0.3.4 (2013-04-29) | ||
------------------ | ||
* Encapsulated option-based instance CLI behaviour with args.invoke(). | ||
* Exposed CLI option config on the exported object to allow ad-hoc | ||
customization for those that `require('combohandler/lib/args')`. | ||
0.3.3 (2013-04-26) | ||
@@ -5,0 +13,0 @@ ------------------ |
@@ -44,2 +44,4 @@ /** | ||
exports = module.exports = { | ||
knownOpts: knownOpts, | ||
shortHands: shortHands, | ||
/*jshint es5: true */ | ||
@@ -115,2 +117,26 @@ get usage() { | ||
return resolveRoots(config); | ||
}, | ||
/** | ||
Encapsulates behaviour of an instance when created via CLI. | ||
@method invoke | ||
@param {ComboCluster} instance | ||
**/ | ||
invoke: function (instance) { | ||
var options = instance.options; | ||
if (options.restart) { | ||
instance.restart(); | ||
} | ||
else if (options.shutdown) { | ||
instance.shutdown(); | ||
} | ||
else if (options.status) { | ||
instance.status(); | ||
} | ||
else if (options.stop) { | ||
instance.stop(); | ||
} | ||
else { | ||
instance.listen(); | ||
} | ||
} | ||
@@ -117,0 +143,0 @@ }; |
{ | ||
"name" : "combohandler", | ||
"description": "Simple Yahoo!-style combo handler.", | ||
"version" : "0.3.3", | ||
"version" : "0.3.4", | ||
"keywords" : [ | ||
@@ -6,0 +6,0 @@ "combo", "combohandler", "combohandle", "combine", "cdn", "css", "yui" |
@@ -6,3 +6,2 @@ /*global describe, it */ | ||
describe("args", function () { | ||
describe("parse()", function () { | ||
@@ -44,2 +43,36 @@ it("should consume ad-hoc string 'restart' param as boolean config.restart", function () { | ||
}); | ||
describe("with augmented knownOpts", function () { | ||
args.knownOpts["ad-hoc-path"] = path; | ||
args.knownOpts["ad-hoc-many"] = [String, Array]; | ||
it("should parse --ad-hoc-path as a resolved path", function () { | ||
var config = args.parse(['--ad-hoc-path', './test/fixtures'], 0); | ||
config.should.have.property('ad-hoc-path'); | ||
config['ad-hoc-path'].should.equal(path.resolve(__dirname, 'fixtures')); | ||
}); | ||
it("should parse --ad-hoc-many as an array of strings", function () { | ||
var config = args.parse([ | ||
'--ad-hoc-many', 'foo', | ||
'--ad-hoc-many', 'bar', | ||
'--ad-hoc-many', 'baz' | ||
], 0); | ||
config.should.have.property('ad-hoc-many'); | ||
config['ad-hoc-many'].should.eql(['foo', 'bar', 'baz']); | ||
}); | ||
}); | ||
describe("with augmented shortHands", function () { | ||
args.shortHands.foo = ["--ad-hoc-path", "./test/fixtures"]; | ||
it("should parse --foo as '--ad-hoc-path ./test/fixtures'", function () { | ||
var config = args.parse(['--foo'], 0); | ||
config.should.have.property('ad-hoc-path'); | ||
config['ad-hoc-path'].should.equal(path.resolve(__dirname, 'fixtures')); | ||
}); | ||
}); | ||
}); | ||
@@ -149,2 +182,22 @@ | ||
}); | ||
describe("invoke()", function () { | ||
function assertMethodCalled(methodName) { | ||
return function (done) { | ||
var instance = { | ||
options: {} | ||
}; | ||
instance[methodName] = done; | ||
instance.options[methodName] = true; | ||
args.invoke(instance); | ||
}; | ||
} | ||
it("should call restart() when options.restart present", assertMethodCalled("restart")); | ||
it("should call shutdown() when options.shutdown present", assertMethodCalled("shutdown")); | ||
it("should call status() when options.status present", assertMethodCalled("status")); | ||
it("should call stop() when options.stop present", assertMethodCalled("stop")); | ||
it("should call listen() when no other options present", assertMethodCalled("listen")); | ||
}); | ||
}); |
@@ -6,4 +6,5 @@ /*global describe, before, after, it */ | ||
describe("defaults", function () { | ||
var DEFAULT_PORT = parseInt(process.env.npm_package_config_port, 10); | ||
var DEFAULT_SERVER = path.resolve(process.env.npm_package_config_server); | ||
var DEFAULT_PORT = parseInt(process.env.npm_package_config_port, 10) || 8000; | ||
var DEFAULT_SERVER = path.resolve(process.env.npm_package_config_server || | ||
path.resolve(__dirname,"../lib/server")); | ||
@@ -10,0 +11,0 @@ describe("for worker", function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128050
2575