Skip to content

Commit

Permalink
Merge pull request #155 from Jezzamonn/watch-dir
Browse files Browse the repository at this point in the history
Add optional --watch-dir command line argument
  • Loading branch information
alallier authored Jun 11, 2018
2 parents 4efbb14 + dbb936c commit e08180d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,9 @@ Options:
-h, --help output usage information
-V, --version output the version number
-b, --browser Open in the browser automatically.
-n, --hostname [hostname] If -b flag is being used, this allows for custom hostnames. Defaults to localhost.
-n, --hostname [hostname] If -b flag is being used, this allows for custom hostnames. Defaults to localhost.
-d, --dir [dir] The directory to serve up. Defaults to current dir.
-w, --watch-dir [watch-dir] The directory to watch. Defaults the serving directory.
-e, --exts [extensions] Extensions separated by commas or pipes. Defaults to html,js,css.
-p, --port [port] The port to bind to. Can be set with PORT env variable as well. Defaults to 8080
-s, --start-page [start-page] Specify a start page. Defaults to index.html
Expand Down
8 changes: 7 additions & 1 deletion bin/reload
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ program.version(require('../package.json').version)
.option('-b, --browser', 'Open in the browser automatically.')
.option('-n, --hostname [hostname]', 'If -b flag is being used, this allows for custom hostnames. Defaults to localhost.', 'localhost')
.option('-d, --dir [dir]', 'The directory to serve up. Defaults to current dir.', process.cwd())
.option('-w, --watch-dir [watch-dir]', 'The directory to watch. Defaults the serving directory.')
.option('-e, --exts [extensions]', 'Extensions separated by commas or pipes. Defaults to html,js,css.', 'html|js|css')
.option('-p, --port [port]', 'The port to bind to. Can be set with PORT env variable as well. Defaults to 8080', '8080')
.option('-s, --start-page [start-page]', 'Specify a start page. Defaults to index.html', 'index.html')
Expand All @@ -23,7 +24,12 @@ if (program.exts.indexOf(',')) {
program.exts = program.exts.replace(/,/g, '|') // replace comma for pipe, that's what supervisor likes
}

var args = ['-e', program.exts, '-w', program.dir, '-q', '--', serverFile, program.port, program.dir, !!program.browser, program.hostname, runFile, program.startPage, program.verbose]
// Fall back to the serving directory.
if (typeof program.watchDir === 'undefined') {
program.watchDir = program.dir
}

var args = ['-e', program.exts, '-w', program.watchDir, '-q', '--', serverFile, program.port, program.dir, !!program.browser, program.hostname, runFile, program.startPage, program.verbose]
supervisor.run(args)

console.log('\nReload web server:')
Expand Down

0 comments on commit e08180d

Please sign in to comment.