Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Only copy URL to clipboard when !open #36

Merged
merged 1 commit into from
Mar 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ that matches:
}
```

_Note: Using the `open` option will disable the `clipboard` option._

##### port

Type: `Number`
Expand Down Expand Up @@ -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
[https-opts]: https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options
2 changes: 1 addition & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
3 changes: 3 additions & 0 deletions test/tests/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down