Skip to content

Commit e5d2ebc

Browse files
committed
Add babelcheck.js
As per matrix-org/matrix-react-sdk@4bea0c0
1 parent 64815b1 commit e5d2ebc

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

babelcheck.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var exec = require('child_process').exec;
2+
3+
// Makes sure the babel executable in the path is babel 6 (or greater), not
4+
// babel 5, which it is if you upgrade from an older version of react-sdk and
5+
// run 'npm install' since the package has changed to babel-cli, so 'babel'
6+
// remains installed and the executable in node_modules/.bin remains as babel
7+
// 5.
8+
9+
// This script is duplicated from matrix-react-sdk because it can't reliably
10+
// be pulled in from react-sdk while npm install is failing, as it will do
11+
// if the environment is in the erroneous state this script checks for.
12+
13+
exec("babel -V", function (error, stdout, stderr) {
14+
if ((error && error.code) || parseInt(stdout.substr(0,1), 10) < 6) {
15+
console.log("\033[31m\033[1m"+
16+
'*****************************************\n'+
17+
'* vector-web has moved to babel 6 *\n'+
18+
'* Please "rm -rf node_modules && npm i" *\n'+
19+
'*****************************************\n'+
20+
"\033[91m");
21+
process.exit(1);
22+
}
23+
});

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"build:bundle": "NODE_ENV=production webpack -p lib/vector/index.js vector/bundle.js",
2020
"build:bundle:dev": "webpack --optimize-occurence-order lib/vector/index.js vector/bundle.js",
2121
"build:staticfiles": "cpx -v node_modules/olm/olm.js vector/",
22-
"build": "npm run build:staticfiles && npm run build:emojione && npm run build:css && npm run build:compile && npm run build:bundle",
22+
"build": "node babelcheck.js && npm run build:staticfiles && npm run build:emojione && npm run build:css && npm run build:compile && npm run build:bundle",
2323
"build:dev": "npm run build:staticfiles && npm run build:emojione && npm run build:css && npm run build:compile && npm run build:bundle:dev",
2424
"package": "scripts/package.sh",
2525
"start:emojione": "cpx \"node_modules/emojione/assets/svg/*\" vector/emojione/svg/ -w",
@@ -28,7 +28,7 @@
2828
"start:skins:css": "catw \"src/skins/vector/css/**/*.css\" -o vector/components.css",
2929
"start:staticfiles": "cpx -Lwv node_modules/olm/olm.js vector/",
3030
"//cache": "Note the -c 1 below due to https://code.google.com/p/chromium/issues/detail?id=508270",
31-
"start": "parallelshell \"npm run start:staticfiles\" \"npm run start:emojione\" \"npm run start:js\" \"npm run start:skins:css\" \"http-server -c 1 vector\"",
31+
"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\"",
3232
"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\"",
3333
"clean": "rimraf lib vector/olm.js vector/bundle.css vector/bundle.js vector/bundle.js.map vector/webpack.css* vector/emojione",
3434
"prepublish": "npm run build:css && npm run build:compile",

0 commit comments

Comments
 (0)