Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detox init remove package.json if there is invalid son #1692

Closed
blakef opened this issue Oct 8, 2019 · 1 comment · Fixed by #1693
Closed

detox init remove package.json if there is invalid son #1692

blakef opened this issue Oct 8, 2019 · 1 comment · Fixed by #1693

Comments

@blakef
Copy link
Contributor

blakef commented Oct 8, 2019

Description

detox init removes the contents of package.json if it contains invalid JSON.

Steps to Reproduce

Add something invalid to package.json, (e.g. a rogue '//') and run detox init -r jest. The contents of package.json with be undefined.

Detox, Node, Device, Xcode and macOS Versions

  • Detox: 14.4.1

Device and verbose Detox logs

$ detox init -r jest
detox[37796] ERROR: [init.js] Failed to create e2e folder, because it already exists at path: /Users/foo/proj/e2e
detox[37796] INFO:  [init.js] Patching package.json at path: /Users/proj/package.json
detox[37796] ERROR: [init.js] Failed to parse package.json due to an error:
/Users/foo/proj/package.json: Unexpected token } in JSON at position 5167
detox[37796] INFO:  [init.js]   json["detox"]["test-runner"] = "jest";

iOS build logs

@blakef
Copy link
Contributor Author

blakef commented Oct 8, 2019

I'd suggest hard failing on encountering an error (would be good to use process.exit). Adding PR.

noomorph pushed a commit that referenced this issue Oct 12, 2019
init now exits and sets an error status of 1 if it can't compelte a
task. This prevents it from breaking package.json badly.

Resolve #1692
@lock lock bot locked as resolved and limited conversation to collaborators Oct 15, 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 a pull request may close this issue.

1 participant