Browse Source

perf: check prop only from metadata of demo (#18332)

* perf: check prop  from metadata of demo

* fix: indent
pull/18329/head
orzyyyy 5 years ago
committed by 偏右
parent
commit
a707050c05
  1. 10
      .circleci/config.yml
  2. 4
      package.json
  3. 14
      scripts/check-demo.js

10
.circleci/config.yml

@ -66,6 +66,9 @@ references:
- test_node_15:
requires:
- setup
- check_metadata:
requires:
- setup
jobs:
setup:
@ -223,6 +226,13 @@ jobs:
- *install_react
- run: npm run test-node -- -w 1 -u
check_metadata:
<<: *container_config
steps:
- checkout
- *attach_workspace
- run: node ./scripts/check-demo.js
workflows:
version: 2
build_test:

4
package.json

@ -136,6 +136,7 @@
"eslint-plugin-react": "^7.14.2",
"eslint-tinker": "^0.5.0",
"fetch-jsonp": "^1.1.3",
"fs-extra": "^8.1.0",
"full-icu": "^1.3.0",
"glob": "^7.1.4",
"husky": "^3.0.2",
@ -186,7 +187,8 @@
"stylelint-order": "^3.0.0",
"typescript": "~3.5.1",
"xhr-mock": "^2.4.1",
"xhr2": "^0.2.0"
"xhr2": "^0.2.0",
"yaml-front-matter": "^4.0.0"
},
"scripts": {
"test": "jest --config .jest.js --no-cache",

14
scripts/check-demo.js

@ -0,0 +1,14 @@
const path = require('path');
const yfm = require('yaml-front-matter');
const glob = require('glob');
const fs = require('fs-extra');
const demoFiles = glob.sync(path.join(process.cwd(), 'components/**/demo/*.md'));
// eslint-disable-next-line no-restricted-syntax
for (const url of demoFiles) {
const demoContent = fs.readFileSync(url);
const meta = yfm.loadFront(demoContent);
if (meta.only) {
throw Error(`there is a 'only': ${url}`);
}
}
Loading…
Cancel
Save