From e5d2ebc57ca5035d1c0cf2b00d45be58169ffe63 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 12 Oct 2016 17:46:11 +0100 Subject: [PATCH] Add babelcheck.js As per https://github.com/matrix-org/matrix-react-sdk/commit/4bea0c0818742908be7d55d9e678201b2d9ba313 --- babelcheck.js | 23 +++++++++++++++++++++++ package.json | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 babelcheck.js diff --git a/babelcheck.js b/babelcheck.js new file mode 100644 index 0000000000..2148d20747 --- /dev/null +++ b/babelcheck.js @@ -0,0 +1,23 @@ +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. + +// This script is duplicated from matrix-react-sdk because it can't reliably +// be pulled in from react-sdk while npm install is failing, as it will do +// if the environment is in the erroneous state this script checks for. + +exec("babel -V", function (error, stdout, stderr) { + if ((error && error.code) || parseInt(stdout.substr(0,1), 10) < 6) { + console.log("\033[31m\033[1m"+ + '*****************************************\n'+ + '* vector-web 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 36b159f188..ac93874199 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "build:bundle": "NODE_ENV=production webpack -p lib/vector/index.js vector/bundle.js", "build:bundle:dev": "webpack --optimize-occurence-order lib/vector/index.js vector/bundle.js", "build:staticfiles": "cpx -v node_modules/olm/olm.js vector/", - "build": "npm run build:staticfiles && npm run build:emojione && npm run build:css && npm run build:compile && npm run build:bundle", + "build": "node babelcheck.js && npm run build:staticfiles && npm run build:emojione && npm run build:css && npm run build:compile && npm run build:bundle", "build:dev": "npm run build:staticfiles && npm run build:emojione && npm run build:css && npm run build:compile && npm run build:bundle:dev", "package": "scripts/package.sh", "start:emojione": "cpx \"node_modules/emojione/assets/svg/*\" vector/emojione/svg/ -w", @@ -28,7 +28,7 @@ "start:skins:css": "catw \"src/skins/vector/css/**/*.css\" -o vector/components.css", "start:staticfiles": "cpx -Lwv node_modules/olm/olm.js vector/", "//cache": "Note the -c 1 below due to https://code.google.com/p/chromium/issues/detail?id=508270", - "start": "parallelshell \"npm run start:staticfiles\" \"npm run start:emojione\" \"npm run start:js\" \"npm run start:skins:css\" \"http-server -c 1 vector\"", + "start": "node babelcheck.js && parallelshell \"npm run start:staticfiles\" \"npm run start:emojione\" \"npm run start:js\" \"npm run start:skins:css\" \"http-server -c 1 vector\"", "start:prod": "parallelshell \"npm run start:staticfiles\" \"npm run start:emojione\" \"npm run start:js:prod\" \"npm run start:skins:css\" \"http-server -c 1 vector\"", "clean": "rimraf lib vector/olm.js vector/bundle.css vector/bundle.js vector/bundle.js.map vector/webpack.css* vector/emojione", "prepublish": "npm run build:css && npm run build:compile",