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

Sanity upgrade fails on unexpected output #301

Closed
bjoerge opened this issue Oct 25, 2017 · 1 comment · Fixed by #331
Closed

Sanity upgrade fails on unexpected output #301

bjoerge opened this issue Oct 25, 2017 · 1 comment · Fixed by #331
Assignees

Comments

@bjoerge
Copy link
Member

bjoerge commented Oct 25, 2017

If a sanity studio has a postinstall script that outputs something to stdout, sanity upgrade will fail with a JSON parse error. I suspect this may also happen if any package in the dependency tree has postinstall script that outputs something else than valid json, but haven't been able to confirm it.

Steps to reproduce:

  1. Run sanity init
  2. Manually install a previous version of any of the packages, e.g with npm install @sanity/base@0.117.0
  3. open package.json, and add the following line to the scripts-section:
    "postinstall": "echo 'postinstall'"
    
  4. Run sanity upgrade

I get the error:




undefined:1
postinstall
^

SyntaxError: Unexpected token p in JSON at position 0
    at DestroyableTransform.parse [as mapper] (<anonymous>)
    at DestroyableTransform.transform [as _transform] (~/.nvm/versions/node/v8.8.0/lib/node_modules/@sanity/cli/node_modules/split2/index.js:33:21)
    at DestroyableTransform.Transform._read (~/.nvm/versions/node/v8.8.0/lib/node_modules/@sanity/cli/node_modules/readable-stream/lib/_stream_transform.js:182:10)
    at DestroyableTransform.Transform._write (~/.nvm/versions/node/v8.8.0/lib/node_modules/@sanity/cli/node_modules/readable-stream/lib/_stream_transform.js:170:83)
    at doWrite (~/.nvm/versions/node/v8.8.0/lib/node_modules/@sanity/cli/node_modules/readable-stream/lib/_stream_writable.js:406:64)
    at writeOrBuffer (~/.nvm/versions/node/v8.8.0/lib/node_modules/@sanity/cli/node_modules/readable-stream/lib/_stream_writable.js:395:5)
    at DestroyableTransform.Writable.write (~/.nvm/versions/node/v8.8.0/lib/node_modules/@sanity/cli/node_modules/readable-stream/lib/_stream_writable.js:322:11)
    at Socket.ondata (_stream_readable.js:639:20)
    at emitOne (events.js:120:20)
    at Socket.emit (events.js:210:7)
@rexxars
Copy link
Member

rexxars commented Nov 5, 2017

Fixed in #331

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants