From 3c4bea1c3b243715aa703b748851d380a031ea87 Mon Sep 17 00:00:00 2001 From: Billy Janitsch Date: Fri, 2 Mar 2018 09:32:00 -0800 Subject: [PATCH] Only copy URL to clipboard when !open --- README.md | 4 +++- lib/server.js | 2 +- test/tests/options.js | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ed76251..8fca045 100644 --- a/README.md +++ b/README.md @@ -284,6 +284,8 @@ that matches: } ``` +_Note: Using the `open` option will disable the `clipboard` option._ + ##### port Type: `Number` @@ -357,4 +359,4 @@ We welcome your contributions! Please have a read of [dev-ware]: https://github.com/webpack/webpack-dev-middleware#options [hot-client]: https://github.com/webpack-contrib/webpack-hot-client#options -[https-opts]: https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options \ No newline at end of file +[https-opts]: https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options diff --git a/lib/server.js b/lib/server.js index 2eb8995..5d3497b 100644 --- a/lib/server.js +++ b/lib/server.js @@ -92,7 +92,7 @@ module.exports = (options) => { server.once('listening', () => { log.info(chalk`Project is running at {blue ${uri}}`); - if (options.clipboard) { + if (options.clipboard && !options.open) { try { clip.writeSync(uri); log.info(chalk.grey('Server URI copied to clipboard')); diff --git a/test/tests/options.js b/test/tests/options.js index 88c18cb..97fa3d8 100644 --- a/test/tests/options.js +++ b/test/tests/options.js @@ -149,9 +149,12 @@ describe('webpack-serve Options', () => { t('should accept an open:Boolean option', (done) => { const config = load('./fixtures/basic/webpack.config.js'); config.serve.open = true; + clip.writeSync('foo'); serve({ config }).then(({ close }) => { hook = (...args) => { + // the open option should disable the clipboard feature + assert.equal(clip.readSync(), 'foo'); assert.equal(args[0], 'http://localhost:8080/'); assert.equal(args[1], true); close(done);