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

[core] Add sanity exec command that registers part loader + babel #138

Merged
merged 1 commit into from
Aug 24, 2017

Conversation

rexxars
Copy link
Member

@rexxars rexxars commented Aug 24, 2017

This adds a new command to the Sanity CLI: exec.
Basically, if you have a studio and have some scripts associated with it that you want to run, it would be nice to be able to use the parts system as you would otherwise, and preferably also be able to use ES6-features.

This is now possible with sanity exec <script.js>. It registers babel with the es2015-node4 and stage-2 presets, and registers the Sanity plugin loader.

For instance, you can now make a script like this:

import client from 'part:@sanity/base/client'

const products = await client.fetch('*[_type == "product"]')
console.log(products)

@rexxars rexxars requested a review from bjoerge August 24, 2017 11:13
Copy link
Member

@bjoerge bjoerge left a comment

Choose a reason for hiding this comment

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

WANT! (and LGTM)

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 this pull request may close these issues.

2 participants