mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-01-12 22:51:18 +08:00
chore: validate path to type definitions on CI
This commit is contained in:
@@ -49,6 +49,7 @@ jobs:
|
||||
at: ~/project
|
||||
- run: |
|
||||
yarn lerna run prepare
|
||||
node scripts/check-types-path.js
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
|
||||
31
scripts/check-types-path.js
Normal file
31
scripts/check-types-path.js
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/* eslint-disable import/no-commonjs */
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const packages = path.join(__dirname, '..', 'packages');
|
||||
|
||||
const invalid = [];
|
||||
|
||||
fs.readdirSync(packages).forEach(name => {
|
||||
const dir = path.join(packages, name);
|
||||
|
||||
if (fs.statSync(path.join(packages, name)).isDirectory()) {
|
||||
const pak = JSON.parse(
|
||||
fs.readFileSync(path.join(dir, 'package.json'), 'utf8')
|
||||
);
|
||||
|
||||
if (pak.types && !fs.existsSync(path.join(dir, pak.types))) {
|
||||
invalid.push(pak);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (invalid.length) {
|
||||
console.log(
|
||||
'Found invalid path to type definitions in the following packages:\n',
|
||||
invalid.map(p => `- ${p.name} (${p.types})`).join('\n')
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user