Skip to content
Myr

Merge pull request #313 from zhiyelee/codestyle

Before adoption: this commit came in with the history the project adopted, so no landing records it.

unify codestyle

authored by Zhiye Li · committed by Zhiye Li · parents 992bcc5, faa6413 · Browse files · 7 files+38 added−30 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

7 files+38 added−30 removed

  • tests:+38 added−30 removed

7 files+38 added−30 removed

modified:test/test.command.action.js+4 added-4 removed
modified:test/test.options.allowUnknown.js+10 added-8 removed
modified:test/test.options.bool.js-1 removed
modified:test/test.options.camelcase.js+1 added-1 removed
modified:test/test.options.coercion.js+2 added-2 removed
modified:test/test.options.commands.js+17 added-12 removed
18 unmodified lines
19 .command('setup [env]')20 .description('run setup commands for all envs')21 .option("-s, --setup_mode [mode]", "Which setup mode to use")22 .option("-o, --host [host]", "Host to use")23 .action(function(env, options){23 .action(function (env, options) {24 var mode = options.setup_mode || "normal";25 env = env || 'all';26 2627 envValue = env;28 });2930program
1 unmodified line
32 .alias('ex')33 .description('execute the given remote cmd')34 .option("-e, --exec_mode <mode>", "Which exec mode to use")35 .option("-t, --target [target]", "Target to use")36 .action(function(cmd, options){36 .action(function (cmd, options) {37 cmdValue = cmd;38 }).on("--help", function(){38 }).on("--help", function () {39 customHelp = true;40 });4142program43 .command('*')44 .action(function(env){44 .action(function (env) {45 console.log('deploying "%s"', env);46 });47 4748program.parse(['node', 'test', '--config', 'conf']);49program.config.should.equal("conf");50program.commands[0].should.not.have.property.setup_mode;51program.commands[1].should.not.have.property.exec_mode;
43 unmodified lines
95// Make sure we still catch errors with required values for options96var exceptionOccurred = false;97var oldProcessExit = process.exit;98var oldConsoleError = console.error;99process.exit = function() { exceptionOccurred = true; throw new Error(); };100console.error = function() {};99process.exit = function () {100 exceptionOccurred = true;101 throw new Error();102};103console.error = function () {104};105106var oldProcessStdoutWrite = process.stdout.write;103process.stdout.write = function () {};107process.stdout.write = function () {108};109try {110 program.parse(['node', 'test', '--config', 'conf6', 'exec', '--help']);106} catch(ex) {111} catch (ex) {112 program.config.should.equal("conf6");113}114process.stdout.write = oldProcessStdoutWrite;115116try {112 program.parse(['node', 'test', '--config', 'conf', 'exec', '-t', 'target1', 'exec1', '-e']);117 program.parse(['node', 'test', '--config', 'conf', 'exec', '-t', 'target1', 'exec1', '-e']);118}114catch(ex) {119catch (ex) {120}121122process.exit = oldProcessExit;123exceptionOccurred.should.be.true;
1 unmodified line
modified:test/test.variadic.args.js+4 added-2 removed
37 unmodified lines
38var oldProcessExit = process.exit;39var oldConsoleError = console.error;40var errorMessage;4142process.exit = function() { throw new Error(consoleErrors.join('\n')); };43console.error = function() {42process.exit = function () {43 throw new Error(consoleErrors.join('\n'));44};45console.error = function () {46 consoleErrors.push(util.format.apply(util, arguments));47};4849try {
15 unmodified lines