From 9434feb009788fab2e6a55dd907103c98ace018d Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 12 Oct 2016 16:53:07 +0100 Subject: [PATCH] Add a script to check the version of babel cli Because the package has changed so npm can't just auto-upgrade, so this at least tells people how to fix it when the upgrade breaks it for everybody. --- babelcheck.js | 19 +++++++++++++++++++ package.json | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 babelcheck.js diff --git a/babelcheck.js b/babelcheck.js new file mode 100644 index 0000000000..75579b1d3d --- /dev/null +++ b/babelcheck.js @@ -0,0 +1,19 @@ +var exec = require('child_process').exec; + +// Makes sure the babel executable in the path is babel 6 (or greater), not +// babel 5, which it is if you upgrade from an older version of react-sdk and +// run 'npm install' since the package has changed to babel-cli, so 'babel' +// remains installed and the executable in node_modules/.bin remains as babel +// 5. + +exec("babel -V", function (error, stdout, stderr) { + if (parseInt(stdout.substr(0,1), 10) < 6) { + console.log("\033[31m\033[1m"+ + '*****************************************\n'+ + '* matrix-react-sdk has moved to babel 6 *\n'+ + '* Please "rm -rf node_modules && npm i" *\n'+ + '*****************************************\n'+ + "\033[91m"); + process.exit(1); + } +}); diff --git a/package.json b/package.json index c17242b591..5b096821c3 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ }, "scripts": { "reskindex": "./reskindex.js -h header", - "build": "babel src -d lib --source-maps", - "start": "babel src -w -d lib --source-maps", + "build": "node babelcheck.js && babel src -d lib --source-maps", + "start": "node babelcheck.js && babel src -w -d lib --source-maps", "lint": "eslint src/", "lintall": "eslint src/ test/", "clean": "rimraf lib", @@ -89,5 +89,8 @@ "sinon": "^1.17.3", "source-map-loader": "^0.1.5", "webpack": "^1.12.14" + }, + "optionalDependencies": { + "babel": "6.5.2" } }