nodemon like option
See original GitHub issueI love estrella, hope you will continue to work on it.
Some users probably have a scenario where they would like to start a the resulting code using node
any time the source changes. Usually this is done using nodemon
. I wrote a little workaround, not being sure if this is a smart way to do it:
#!/usr/bin/env node
const pkg = require('./package.json')
const common = require('./build.config.js')
const { spawn } = require('child_process')
const { build } = require('estrella')
let node
build({
...common,
entry: 'src/index.js',
outfile: pkg.main,
onEnd(config, result) {
if (config.watch) {
if (node) {
node.kill('SIGHUP')
node = null
}
if (result.errors.length > 0) {
console.error(`Build failed with ${result.errors.length} errors`)
} else {
console.info(`Build succeeded. Launching 'node ${pkg.main}'`)
node = spawn('node', [pkg.main], {
shell: true,
stdio: 'inherit',
})
}
}
},
})
In case it is, it would be great to get an estrella option to say, start the outFile
with node, like:
#!/usr/bin/env node
const pkg = require('./package.json')
const common = require('./build.config.js')
const { buildAndRun } = require('estrella')
buildAndRun({
...common,
entry: 'src/index.js',
outfile: pkg.main
})
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
remy/nodemon: Monitor for any changes in your node ... - GitHub
nodemon is a tool that helps develop Node.js based applications by automatically restarting the node application when file changes in the directory are...
Read more >List of Various Alternative of Nodemon - eduCBA
Here we have discussed the various alternatives to nodemon such as gulp, grunt, webpack, NodeFly, LiveReload, and PM2. Each has its own features...
Read more >nodemon
Nodemon is a utility depended on about 3 million projects, that will monitor for any changes in your source and automatically restart your...
Read more >How To Restart Your Node.js Apps Automatically with nodemon
Step 3 — Using Options · --exec : Use the --exec switch to specify a binary to execute the file with. · --ext...
Read more >Configuring nodemon with TypeScript - LogRocket Blog
Well, the simplicity offered by nodemon diminishes both as you ... we will discuss whether or not each option will suit the needs...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Landed in v1.2.0 which was just released.
API: https://github.com/rsms/estrella/blob/v1.2.0/estrella.d.ts#L93-L130
Example: https://github.com/rsms/estrella/tree/v1.2.0/examples/run
@holtwick let me know what you think and how it’s working for you. Thanks for the collaboration!
Thanks @rsms for adding the feature. In general, it works great.
Some little things might be nice: to have as well:
run
option’s documentation to theREADME.md
file-r
or-run
option. It seems to be missing here. It is important, because if somebody wants to build for production, the code is still run. Alternatively the code should only be executed if-w
is active. A workaround would be to handle this in thebuild.js
script itself, but that’s not very attractive IMO.