diff --git a/lib/watch.js b/lib/watch.js index 2015f20..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 }) + const project = new Spike({ root: args.path, env: args.env, server: { port: args.port } }) process.nextTick(() => project.watch()) return project } 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)