Commands run with netlify dev's `--command` flag always exit with code 1. Successful commands should exit with code 0.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 474
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 53
Description
Is your feature request related to a problem? Please describe.
I'm using the --command flag to run integration tests together with Netlify dev server. This way the Netlify dev server stops automatically when tests are done. The exit code is always 1 (unfortunately), even if all tests succeed.
Here is an example of the command I'm running: NODE_ENV=test netlify dev --command=ava.
Describe the solution you'd like
I'd like the netlify dev to return exit code 0 if the command that was executed by --command flag returns 0.
Describe alternatives you've considered
I've made slight modification using the patch package in my node_modules, inside of netlify-cli folder.
Additional context
This seems to be caused by this line of code.
Can you submit a pull request?
Yes, I have a change prepared in a forked repo. Some tests however keep failing:
➜ cli git:(feature/exit-code-zero-on-successful-command) ✗ ava tests/framework-detection.test.js --match "should pass framework-info env to framework sub process"
Starting dev server on port: 17478 in directory site-with-gatsby
should pass framework-info env to framework sub process
tests/framework-detection.test.js:301
300: const error = await t.throwsAsync(() => withDevServer({ cwd: builder.directory }, () => {}, true))
301: t.snapshot(normalize(error.stdout))
302: })
Rejected promise returned by test. Reason:
TypeError {
message: 'Cannot read properties of undefined (reading \'replace\')',
}
› tests/utils/snapshots.js:17:55
› Array.reduce (<anonymous>)
› normalize (tests/utils/snapshots.js:17:15)
› tests/framework-detection.test.js:301:16
› withSiteBuilder (tests/utils/site-builder.js:188:12)
› tests/framework-detection.test.js:288:3
─
1 test failed
Pull requests are welcome! If you would like to help us add this feature, please check our
contributions guidelines.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The behavior is called out in src/commands/dev/dev.js around line 106, with a proposed change near line 102 in the linked fork. Start there, then investigate the failing tests/framework-detection.test.js case and normalization in tests/utils/snapshots.js; done means a successful --command returns exit code 0 without breaking those tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- cli, testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100