Check that generated compat-data is up to date on CI (#11024)
This commit is contained in:
parent
de75dbf2a0
commit
2b23c283dd
8
Makefile
8
Makefile
@ -101,7 +101,7 @@ bootstrap-flowcheck: bootstrap-only
|
|||||||
$(YARN) gulp build-babel-types
|
$(YARN) gulp build-babel-types
|
||||||
$(MAKE) build-typings
|
$(MAKE) build-typings
|
||||||
|
|
||||||
lint-ci: lint-js-ci lint-ts-ci
|
lint-ci: lint-js-ci lint-ts-ci check-compat-data
|
||||||
|
|
||||||
lint-js-ci: bootstrap-only
|
lint-js-ci: bootstrap-only
|
||||||
$(MAKE) lint-js
|
$(MAKE) lint-js
|
||||||
@ -125,6 +125,12 @@ fix-js:
|
|||||||
fix-json:
|
fix-json:
|
||||||
$(YARN) prettier "{$(COMMA_SEPARATED_SOURCES)}/*/test/fixtures/**/options.json" --write --loglevel warn
|
$(YARN) prettier "{$(COMMA_SEPARATED_SOURCES)}/*/test/fixtures/**/options.json" --write --loglevel warn
|
||||||
|
|
||||||
|
check-compat-data:
|
||||||
|
cd packages/babel-compat-data; CHECK_COMPAT_DATA=true $(YARN) run build-data
|
||||||
|
|
||||||
|
build-compat-data:
|
||||||
|
cd packages/babel-compat-data; $(YARN) run build-data
|
||||||
|
|
||||||
clean: test-clean
|
clean: test-clean
|
||||||
rm -f .npmrc
|
rm -f .npmrc
|
||||||
rm -rf packages/babel-polyfill/browser*
|
rm -rf packages/babel-polyfill/browser*
|
||||||
|
|||||||
@ -4,7 +4,6 @@ const fs = require("fs");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const semver = require("semver");
|
const semver = require("semver");
|
||||||
const flattenDeep = require("lodash/flattenDeep");
|
const flattenDeep = require("lodash/flattenDeep");
|
||||||
const isEqual = require("lodash/isEqual");
|
|
||||||
const mapValues = require("lodash/mapValues");
|
const mapValues = require("lodash/mapValues");
|
||||||
const pickBy = require("lodash/pickBy");
|
const pickBy = require("lodash/pickBy");
|
||||||
const { unreleasedLabels } = require("@babel/helper-compilation-targets");
|
const { unreleasedLabels } = require("@babel/helper-compilation-targets");
|
||||||
@ -297,18 +296,20 @@ for (const target of ["plugin", "corejs2-built-in"]) {
|
|||||||
);
|
);
|
||||||
const dataPath = path.join(__dirname, `../data/${target}s.json`);
|
const dataPath = path.join(__dirname, `../data/${target}s.json`);
|
||||||
|
|
||||||
if (process.argv[2] === "--check") {
|
const stringified = JSON.stringify(newData, null, 2) + "\n";
|
||||||
const currentData = require(dataPath);
|
if (process.env.CHECK_COMPAT_DATA) {
|
||||||
|
const currentData = fs.readFileSync(dataPath, "utf8");
|
||||||
|
|
||||||
if (!isEqual(currentData, newData)) {
|
// Compare as JSON strings to also check keys ordering
|
||||||
|
if (currentData !== stringified) {
|
||||||
console.error(
|
console.error(
|
||||||
"The newly generated plugin/built-in data does not match the current " +
|
"The newly generated plugin/built-in data does not match the current " +
|
||||||
"files. Re-run `npm run build-data`."
|
"files. Re-run `make build-compat-data`."
|
||||||
);
|
);
|
||||||
process.exitCode = 1;
|
process.exitCode = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fs.writeFileSync(dataPath, `${JSON.stringify(newData, null, 2)}\n`);
|
fs.writeFileSync(dataPath, stringified);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user