question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nodemon like option

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
rsmscommented, Sep 27, 2020

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!

1reaction
holtwickcommented, Sep 28, 2020

Thanks @rsms for adding the feature. In general, it works great.

Some little things might be nice: to have as well:

  • Add the run option’s documentation to the README.md file
  • In my PR I added a -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 the build.js script itself, but that’s not very attractive IMO.
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found