Repository: cordova-cli Updated Branches: refs/heads/master eef875c63 -> 72008357b
CB-12570 : fetch is true by default and added new tests to test if fetch is the default and test the --nofetch flag Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/0b8005c7 Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/0b8005c7 Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/0b8005c7 Branch: refs/heads/master Commit: 0b8005c787be0be4d3592433d68779ad69c84ad0 Parents: eef875c Author: Audrey So <[email protected]> Authored: Tue Mar 14 16:45:56 2017 -0700 Committer: Steve Gill <[email protected]> Committed: Wed Apr 19 17:54:34 2017 -0700 ---------------------------------------------------------------------- spec/cli.spec.js | 52 ++++++++++++++++++++++++++++++++------------------- src/cli.js | 13 +++++++++---- 2 files changed, 42 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0b8005c7/spec/cli.spec.js ---------------------------------------------------------------------- diff --git a/spec/cli.spec.js b/spec/cli.spec.js index dd5c18b..76b05d4 100644 --- a/spec/cli.spec.js +++ b/spec/cli.spec.js @@ -92,42 +92,42 @@ describe("cordova cli", function () { it("Test#005 : will call command with all arguments passed through", function (done) { cli(["node", "cordova", "build", "blackberry10", "--", "-k", "abcd1234"], function () { - expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { argv: ['-k', 'abcd1234'] }, verbose: false, silent: false, browserify: false, nohooks: [], searchpath: undefined, fetch: false }); + expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { argv: ['-k', 'abcd1234'], fetch: true }, verbose: false, silent: false, browserify: false, fetch: true, nohooks: [ ], searchpath: undefined }); done(); }); }, 60000); it("Test#006 : will consume the first instance of -d", function (done) { cli(["node", "cordova", "-d", "build", "blackberry10", "--", "-k", "abcd1234", "-d"], function () { - expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { verbose: true, argv: ['-k', 'abcd1234', '-d'] }, verbose: true, silent: false, browserify: false, nohooks: [], searchpath: undefined, fetch: false }); + expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { verbose: true, argv: ['-k', 'abcd1234', '-d'], fetch: true }, verbose: true, silent: false, browserify: false, fetch: true, nohooks: [ ], searchpath: undefined }); done(); }); }); it("Test#007 : will consume the first instance of --verbose", function (done) { cli(["node", "cordova", "--verbose", "build", "blackberry10", "--", "-k", "abcd1234", "--verbose"], function () { - expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { verbose: true, argv: ['-k', 'abcd1234', '--verbose'] }, verbose: true, silent: false, browserify: false, nohooks: [], searchpath: undefined, fetch: false }); + expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { verbose: true, argv: ['-k', 'abcd1234', '--verbose'], fetch: true }, verbose: true, silent: false, browserify: false, fetch: true, nohooks: [ ], searchpath: undefined }); done(); }); }); it("Test#008 : will consume the first instance of either --verbose or -d", function (done) { cli(["node", "cordova", "--verbose", "build", "blackberry10", "--", "-k", "abcd1234", "-d"], function () { - expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { verbose: true, argv: ['-k', 'abcd1234', '-d'] }, verbose: true, silent: false, browserify: false, nohooks: [], searchpath: undefined, fetch: false }); + expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { verbose: true, argv: ['-k', 'abcd1234', '-d'], fetch: true }, verbose: true, silent: false, browserify: false, fetch: true, nohooks: [ ], searchpath: undefined }); done(); }); }); it("Test#009 : will consume the first instance of either --verbose or -d", function (done) { cli(["node", "cordova", "-d", "build", "blackberry10", "--", "-k", "abcd1234", "--verbose"], function () { - expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { verbose: true, argv: ['-k', 'abcd1234', '--verbose'] }, verbose: true, silent: false, browserify: false, nohooks: [], searchpath: undefined, fetch: false }); + expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { verbose: true, argv: ['-k', 'abcd1234', '--verbose'], fetch: true }, verbose: true, silent: false, browserify: false, fetch: true, nohooks: [ ], searchpath: undefined }); done(); }); }); it("Test#010 : will consume the first instance of --silent", function (done) { cli(["node", "cordova", "--silent", "build", "blackberry10", "--", "-k", "abcd1234", "--silent"], function () { - expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { silent: true, argv: ['-k', 'abcd1234', '--silent'] }, verbose: false, silent: true, browserify: false, nohooks: [], searchpath: undefined, fetch: false }); + expect(cordova.raw.build).toHaveBeenCalledWith({ platforms: ['blackberry10'], options: { silent: true, argv: ['-k', 'abcd1234', '--silent'], fetch: true }, verbose: false, silent: true, browserify: false, fetch: true, nohooks: [ ], searchpath: undefined }); done(); }); }); @@ -203,19 +203,6 @@ describe("cordova cli", function () { }); }); - it("Test #016 : autosave is default and will pass save:true", function (done) { - cli(["node", "cordova", "plugin", "add", "device"], function () { - expect(cordova.raw.plugin).toHaveBeenCalledWith( - "add", - ["device"], - jasmine.any(Object) - ); - var opts = cordova.raw.plugin.calls.argsFor(0)[2]; - expect(opts.save).toBe(true); - done(); - }); - }); - it("Test #017 : will pass save:false", function (done) { cli(["node", "cordova", "plugin", "remove", "device", "--nosave"], function () { expect(cordova.raw.plugin).toHaveBeenCalledWith( @@ -460,6 +447,32 @@ describe("platform", function () { done(); }); }); + + it("Test #036 : will pass fetch:false", function (done) { + cli(["node", "cordova", "platform", "add", "device", "--nofetch"], function () { + expect(cordova.raw.platform).toHaveBeenCalledWith( + "add", + ["device"], + jasmine.any(Object) + ); + var opts = cordova.raw.platform.calls.argsFor(0)[2]; + expect(opts.fetch).toBe(false); + done(); + }); + }); + + it("Test #037 : fetch is true by default and will pass fetch:true", function (done) { + cli(["node", "cordova", "platform", "add", "device"], function () { + expect(cordova.raw.platform).toHaveBeenCalledWith( + "add", + ["device"], + jasmine.any(Object) + ); + var opts = cordova.raw.platform.calls.argsFor(0)[2]; + expect(opts.fetch).toBe(true); + done(); + }); + }); }); describe("config", function () { @@ -550,3 +563,4 @@ describe("config", function () { }); }); }); + http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/0b8005c7/src/cli.js ---------------------------------------------------------------------- diff --git a/src/cli.js b/src/cli.js index 35776ad..bdda821 100644 --- a/src/cli.js +++ b/src/cli.js @@ -354,13 +354,19 @@ function cli(inputArgs) { throw new CordovaError(msg2); } + if (args.nofetch) { + args.fetch = false; + } else { + args.fetch = true; + } + var opts = { platforms: [], options: [], verbose: args.verbose || false, silent: args.silent || false, browserify: args.browserify || false, - fetch: args.fetch || false, + fetch: args.fetch, nohooks: args.nohooks || [], searchpath : args.searchpath }; @@ -377,7 +383,6 @@ function cli(inputArgs) { if (cmd === 'run' && args.list && cordova.raw.targets) { return cordova.raw.targets.call(null, opts); } - return cordova.raw[cmd].call(null, opts); } else if (cmd === 'requirements') { @@ -448,7 +453,6 @@ function cli(inputArgs) { args.save = false; } else { args.save = true; - } if (args.save === undefined) { // User explicitly did not pass in save @@ -468,11 +472,12 @@ function cli(inputArgs) { , nohooks : args.nohooks , cli_variables : cli_vars , browserify: args.browserify || false - , fetch: args.fetch || false + , fetch: args.fetch , link: args.link || false , save: args.save , shrinkwrap: args.shrinkwrap || false , force: args.force || false + }; return cordova.raw[cmd](subcommand, targets, download_opts); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
