-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from aaronshaf/feature/open-browser
Add --open argument to open default browser with GUI on start (fix #23)
- Loading branch information
Showing
4 changed files
with
42 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,40 @@ | ||
#!/usr/bin/env node | ||
|
||
const ArgumentParser = require('argparse').ArgumentParser | ||
const opn = require('opn') | ||
const packageJson = require('../package.json') | ||
|
||
const { createServer } = require('../lib/backend') | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
console.error(clc.red('Do not run this in production!')) | ||
process.exit(1) | ||
} | ||
|
||
const parser = new ArgumentParser({ | ||
description: packageJson.description, | ||
version: packageJson.version, | ||
}) | ||
|
||
parser.addArgument(['-o', '--open'], { | ||
action: 'storeTrue', | ||
help: 'Open server URL in default browser on start', | ||
}) | ||
|
||
const args = parser.parseArgs() | ||
|
||
console.log('dynamodb-admin') | ||
|
||
const app = createServer(); | ||
const port = process.env.PORT || 8001 | ||
const server = app.listen(port); | ||
server.on('listening', () => { | ||
const address = server.address(); | ||
console.log(` listening on http://0.0.0.0:${address.port}`); | ||
const url = `http://0.0.0.0:${address.port}`; | ||
console.log(` listening on ${url}`); | ||
|
||
if (args.open) { | ||
opn(url) | ||
} | ||
}); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters