From 4892bad7a58b3e385b497c489d71f4dd97c6c8b7 Mon Sep 17 00:00:00 2001 From: David Eglin Date: Mon, 21 Nov 2016 16:52:11 +0000 Subject: [PATCH 1/3] fix watch to properly pass port variable to browsersync opts --- lib/watch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/watch.js b/lib/watch.js index 2015f20..68c0ca2 100644 --- a/lib/watch.js +++ b/lib/watch.js @@ -1,5 +1,5 @@ module.exports = function (Spike, args) { - const project = new Spike({ root: args.path, env: args.env }) + const project = new Spike({ root: args.path, env: args.env, server: { port: args.port }}) process.nextTick(() => project.watch()) return project } From ce6eba2bdd298cfdf9ad5a2b443aafe285d82623 Mon Sep 17 00:00:00 2001 From: David Eglin Date: Mon, 21 Nov 2016 17:10:55 +0000 Subject: [PATCH 2/3] update spacing for code linting --- lib/watch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/watch.js b/lib/watch.js index 68c0ca2..8a8cb53 100644 --- a/lib/watch.js +++ b/lib/watch.js @@ -1,5 +1,5 @@ module.exports = function (Spike, args) { - const project = new Spike({ root: args.path, env: args.env, server: { port: args.port }}) + const project = new Spike({ root: args.path, env: args.env, server: { port: args.port } }) process.nextTick(() => project.watch()) return project } From aecc715ec6eb5598c799cf17c37d9a63f0f5a8b3 Mon Sep 17 00:00:00 2001 From: David Eglin Date: Mon, 21 Nov 2016 17:19:45 +0000 Subject: [PATCH 3/3] add tests for watch command - with and without port argument --- test/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/index.js b/test/index.js index 29028c5..6a69fd3 100644 --- a/test/index.js +++ b/test/index.js @@ -121,6 +121,7 @@ test.cb('watch', (t) => { cli.on('warning', t.end) cli.on('compile', (res) => { t.is(res, 'watch mock') + t.falsy(mock.opts.server.port) t.end() }) @@ -138,6 +139,17 @@ test.cb('watch with env option', (t) => { cli.run('watch -e production') }) +test.cb('watch with port option', (t) => { + cli.on('error', t.end) + cli.on('warning', t.end) + cli.on('compile', (res) => { + t.is(mock.opts.server.port, 1118) + t.end() + }) + + cli.run('watch -p 1118') +}) + test.cb('add', (t) => { cli.on('error', t.end) cli.on('warning', t.end)