feat: add --copy option for vue-cli-service serve (#1355)

This commit is contained in:
Craig Morris
2018-05-29 13:59:10 +01:00
committed by Evan You
parent 3bcc511507
commit 5e95b3df73
5 changed files with 11 additions and 1 deletions
+1
View File
@@ -32,6 +32,7 @@ Usage: vue-cli-service serve [options]
Options:
--open open browser on server start
--copy copy url to clipboard on server start
--mode specify env mode (default: development)
--host specify host (default: 0.0.0.0)
--port specify port (default: 8080)
+1
View File
@@ -174,6 +174,7 @@ serve a .js or .vue file in development mode with zero config
Options:
-o, --open Open browser
-c, --copy Copy local url to clipboard
-h, --help output usage information
```
@@ -159,10 +159,16 @@ module.exports = (api, options) => {
return
}
let copied = ''
if (isFirstCompile && args.copy) {
require('clipboardy').write(urls.localUrlForBrowser)
copied = chalk.dim('(copied to clipboard)')
}
console.log()
console.log([
` App running at:`,
` - Local: ${chalk.cyan(urls.localUrlForTerminal)}`,
` - Local: ${chalk.cyan(urls.localUrlForTerminal)} ${copied}`,
` - Network: ${chalk.cyan(urls.lanUrlForTerminal)}`
].join('\n'))
console.log()
+1
View File
@@ -31,6 +31,7 @@
"cache-loader": "^1.2.2",
"case-sensitive-paths-webpack-plugin": "^2.1.2",
"chalk": "^2.4.1",
"clipboardy": "^1.2.3",
"cliui": "^4.1.0",
"copy-webpack-plugin": "^4.5.1",
"css-loader": "^0.28.11",
+1
View File
@@ -82,6 +82,7 @@ program
.command('serve [entry]')
.description('serve a .js or .vue file in development mode with zero config')
.option('-o, --open', 'Open browser')
.option('-c, --copy', 'Copy local url to clipboard')
.action((entry, cmd) => {
loadCommand('serve', '@vue/cli-service-global').serve(entry, cleanArgs(cmd))
})