Skip to content

Commit

Permalink
feat(cli): add stdin flag to serve (#2411)
Browse files Browse the repository at this point in the history
* feat(cli): add stdin flag to serve

* add back --public help

* reorder help
  • Loading branch information
nullpilot authored and sodatea committed Jan 10, 2020
1 parent cb3db60 commit fff9caa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/@vue/cli-service/lib/commands/serve.js
Expand Up @@ -19,6 +19,7 @@ module.exports = (api, options) => {
options: {
'--open': `open browser on server start`,
'--copy': `copy url to clipboard on server start`,
'--stdin': `close when stdin ends`,
'--mode': `specify env mode (default: development)`,
'--host': `specify host (default: ${defaults.host})`,
'--port': `specify port (default: ${defaults.port})`,
Expand Down Expand Up @@ -204,6 +205,16 @@ module.exports = (api, options) => {
})
})

if (args.stdin) {
process.stdin.on('end', () => {
server.close(() => {
process.exit(0)
})
})

process.stdin.resume()
}

// on appveyor, killing the process with SIGTERM causes execa to
// throw error
if (process.env.VUE_CLI_TEST) {
Expand Down

0 comments on commit fff9caa

Please sign in to comment.