Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

run-wrangler.js: send error to stderr and exit 1 if child process has an error #857

Merged
merged 3 commits into from
Nov 8, 2019

Conversation

jaredmcdonald
Copy link
Contributor

fixes #848

ideally i'd add some tests but there doesn't seem to be a test suite for the npm shim. let me know if you have any preference there or if it's fine to just leave untested.

before:

> ./npm/run-wrangler.js --version
👷 ✨  wrangler 1.5.0
> mv ~/.wrangler/out/wrangler ~/.wrangler/out/wrangler.bak
> ./npm/run-wrangler.js --version
> echo $status
0

after:

> ./npm/run-wrangler.js --version
👷 ✨  wrangler 1.5.0
> mv ~/.wrangler/out/wrangler ~/.wrangler/out/wrangler.bak
jared@Jareds-MBP-2 ~/p/wrangler> ./npm/run-wrangler.js --version
{ Error: spawnSync /Users/jared/.wrangler/out/wrangler ENOENT
    at _errnoException (util.js:992:11)
    at spawnSync (child_process.js:579:20)
    at Object.<anonymous> (/Users/jared/projects/wrangler/npm/run-wrangler.js:16:16)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'spawnSync /Users/jared/.wrangler/out/wrangler',
  path: '/Users/jared/.wrangler/out/wrangler',
  spawnargs: [ '--version' ] }
> echo $status
1

Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect! Not gonna make you start a test suite but feel free to open a separate PR we will not turn them away 😄

@EverlastingBugstopper EverlastingBugstopper merged commit c3deb57 into cloudflare:master Nov 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

run-wrangler.js exits 0 if wrangler binary not found
2 participants