Skip to content

Commit

Permalink
chore: download compat-table when build-data is run (#10873)
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung authored and existentialism committed Dec 18, 2019
1 parent c35ba3d commit ff8a295
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions packages/babel-preset-env/.gitignore
Expand Up @@ -8,3 +8,4 @@ test/tmp
.nyc_output
tmp
babel-preset-env-*.tgz
/build
1 change: 1 addition & 0 deletions packages/babel-preset-env/.npmignore
Expand Up @@ -15,3 +15,4 @@ babel-preset-env-*.tgz
flow-typed
.github
.idea
/build
4 changes: 2 additions & 2 deletions packages/babel-preset-env/CONTRIBUTING.md
Expand Up @@ -63,9 +63,9 @@ If you want to mark a new proposal as shipped, add it to [this list](https://git

### Update [`plugins.json`](https://github.com/babel/babel/blob/master/packages/babel-preset-env/data/plugins.json)

Until `compat-table` is a standalone npm module for data we are using the git url
Until `compat-table` is a standalone npm module for data we are using the git commit in `scripts/download-compat-table.sh`

`"compat-table": "kangax/compat-table#[latest-commit-hash]"`,
`COMPAT_TABLE_COMMIT=[latest-commit-hash]`,

So we update and then run `npm run build-data`. If there are no changes, then `plugins.json` will be the same.

Expand Down
3 changes: 1 addition & 2 deletions packages/babel-preset-env/package.json
Expand Up @@ -11,7 +11,7 @@
"repository": "https://github.com/babel/babel/tree/master/packages/babel-preset-env",
"main": "lib/index.js",
"scripts": {
"build-data": "node ./scripts/build-data.js; node ./scripts/build-modules-support.js"
"build-data": "./scripts/download-compat-table.sh; node ./scripts/build-data.js; node ./scripts/build-modules-support.js"
},
"dependencies": {
"@babel/helper-module-imports": "^7.7.4",
Expand Down Expand Up @@ -76,7 +76,6 @@
"@babel/helper-plugin-test-runner": "^7.7.4",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"caniuse-db": "1.0.30000969",
"compat-table": "kangax/compat-table#4195aca631ad904cb0efeb62a9c2d8c8511706f8",
"electron-to-chromium": "1.3.113"
}
}
4 changes: 2 additions & 2 deletions packages/babel-preset-env/scripts/build-data.js
Expand Up @@ -46,7 +46,7 @@ const renameTests = (tests, getName, category) =>
// environments (node4 and chrome45), as well as familial relationships (edge
// and ie11) can be handled properly.

const envs = require("compat-table/environments");
const envs = require("../build/compat-table/environments");

const byTestSuite = suite => browser => {
return Array.isArray(browser.test_suites)
Expand All @@ -56,7 +56,7 @@ const byTestSuite = suite => browser => {

const compatSources = ["es5", "es6", "es2016plus", "esnext"].reduce(
(result, source) => {
const data = require(`compat-table/data-${source}`);
const data = require(`../build/compat-table/data-${source}`);
data.browsers = pickBy(envs, byTestSuite(source));
result.push(data);
return result;
Expand Down
8 changes: 8 additions & 0 deletions packages/babel-preset-env/scripts/download-compat-table.sh
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

COMPAT_TABLE_COMMIT=4195aca631ad904cb0efeb62a9c2d8c8511706f8
rm -rf build/compat-table
mkdir -p build
git clone --branch=gh-pages --single-branch --shallow-since=2019-11-14 https://github.com/kangax/compat-table.git build/compat-table
cd build/compat-table && git checkout -qf $COMPAT_TABLE_COMMIT

0 comments on commit ff8a295

Please sign in to comment.