diff --git a/packages/@sanity/core/package.json b/packages/@sanity/core/package.json index 5494026a872..9b97bf9ca3a 100644 --- a/packages/@sanity/core/package.json +++ b/packages/@sanity/core/package.json @@ -16,9 +16,13 @@ "dependencies": { "@sanity/check": "^0.108.0", "@sanity/mutator": "^0.108.0", + "@sanity/plugin-loader": "^0.108.0", "@sanity/resolver": "^0.108.0", "@sanity/server": "^0.108.0", "@sanity/util": "^0.108.0", + "babel-preset-es2015-node4": "^2.1.1", + "babel-preset-stage-2": "^6.22.0", + "babel-register": "^6.26.0", "batch-stream-operation": "^1.0.2", "debug": "^2.6.3", "deep-sort-object": "^1.0.1", @@ -43,8 +47,6 @@ }, "devDependencies": { "babel-plugin-lodash": "^3.2.11", - "babel-preset-es2015-node4": "^2.1.1", - "babel-preset-stage-2": "^6.22.0", "chai": "^3.5.0", "chai-as-promised": "^6.0.0", "eslint": "^3.19.0", diff --git a/packages/@sanity/core/src/actions/exec/babel.js b/packages/@sanity/core/src/actions/exec/babel.js new file mode 100644 index 00000000000..9da644916f2 --- /dev/null +++ b/packages/@sanity/core/src/actions/exec/babel.js @@ -0,0 +1,5 @@ +const presets = ['es2015-node4', 'stage-2'] + +require('babel-register')({ + presets: presets.map(preset => require.resolve(`babel-preset-${preset}`)), +}) diff --git a/packages/@sanity/core/src/actions/exec/execScript.js b/packages/@sanity/core/src/actions/exec/execScript.js new file mode 100644 index 00000000000..58227570d04 --- /dev/null +++ b/packages/@sanity/core/src/actions/exec/execScript.js @@ -0,0 +1,24 @@ +const spawn = require('child_process').spawn +const fsp = require('fs-promise') +const path = require('path') + +module.exports = async args => { + const [script] = args.argsWithoutOptions + const scriptPath = path.resolve(script) + + if (!script) { + throw new Error('SCRIPT must be provided. `sanity exec