From 70868de81b6a0ed48294fb098e8547ec6c581e46 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 19:29:19 +0900 Subject: [PATCH 1/3] changes undefined process.exit(code) to process.exit(9) --- lib/cmd.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cmd.js b/lib/cmd.js index a3440b974..d28a1b9d3 100644 --- a/lib/cmd.js +++ b/lib/cmd.js @@ -33,10 +33,11 @@ Cmd.prototype.newApp = function() { .description('new application') .action(function(name, options) { if (name === undefined) { + console.log("please specify your app Name".red); console.log("e.g embark new MyApp".green); console.log("e.g embark new --help for more information".green); - process.exit(code); + process.exit(9); } self.Embark.generateTemplate('boilerplate', './', name); }); From 895b2477cdd022c307ccda024eae5d52b701e093 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 22:52:06 +0900 Subject: [PATCH 2/3] added unit test for Embark.Cmd --- test/cmd.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 test/cmd.js diff --git a/test/cmd.js b/test/cmd.js new file mode 100644 index 000000000..5afe1e45f --- /dev/null +++ b/test/cmd.js @@ -0,0 +1,30 @@ +var Embark = require('../lib/index'); +var Cmd = require('../lib/cmd'); + +describe('embark.Cmd', function () { + var cmd = new Cmd(Embark); + + describe('#new', function () { + it('it should not create an app without a name', function (done) { + cmd.newApp(undefined, function (output) { + let lines = output.split('\n'); + assert.equal(lines[0], 'please specify your app Name'); + assert.equal(lines[1], 'e.g embark new MyApp'); + assert.equal(lines[2], 'e.g embark new --help for more information'); + }); + done(); + }); + + it('it should create an app with a name', function (done) { + let appname = 'deleteapp'; + cmd.newApp(appname, function (output) { + let lines = output.split('\n'); + assert.equal(lines[0], 'Initializing Embark Template....'); + assert.equal(lines[1], 'Installing packages.. this can take a few seconds'); + assert.equal(lines[2], 'Init complete'); + assert.equal(lines[3], 'App ready at ./' + appname); + }); + done(); + }); + }); +}); \ No newline at end of file From 6f5abfe07c92398df0eaba618a7da919ff66d7b5 Mon Sep 17 00:00:00 2001 From: Todd Baur Date: Wed, 8 Mar 2017 22:56:27 +0900 Subject: [PATCH 3/3] swap let -> var --- test/cmd.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/cmd.js b/test/cmd.js index 5afe1e45f..8b64a97dd 100644 --- a/test/cmd.js +++ b/test/cmd.js @@ -7,7 +7,7 @@ describe('embark.Cmd', function () { describe('#new', function () { it('it should not create an app without a name', function (done) { cmd.newApp(undefined, function (output) { - let lines = output.split('\n'); + var lines = output.split('\n'); assert.equal(lines[0], 'please specify your app Name'); assert.equal(lines[1], 'e.g embark new MyApp'); assert.equal(lines[2], 'e.g embark new --help for more information'); @@ -16,9 +16,9 @@ describe('embark.Cmd', function () { }); it('it should create an app with a name', function (done) { - let appname = 'deleteapp'; + var appname = 'deleteapp'; cmd.newApp(appname, function (output) { - let lines = output.split('\n'); + var lines = output.split('\n'); assert.equal(lines[0], 'Initializing Embark Template....'); assert.equal(lines[1], 'Installing packages.. this can take a few seconds'); assert.equal(lines[2], 'Init complete');