mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
feat(cli): optimize getComponent method
This commit is contained in:
parent
1161fea30f
commit
cc26929ebc
@ -1,5 +1,5 @@
|
|||||||
import decamelize from 'decamelize';
|
import decamelize from 'decamelize';
|
||||||
import { readdirSync, existsSync, lstatSync } from 'fs-extra';
|
import { readdirSync, existsSync, lstatSync, readFileSync } from 'fs-extra';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { SRC_DIR, WEBPACK_CONFIG_FILE } from './constant';
|
import { SRC_DIR, WEBPACK_CONFIG_FILE } from './constant';
|
||||||
|
|
||||||
@ -25,7 +25,14 @@ export function getComponents() {
|
|||||||
return dirs
|
return dirs
|
||||||
.filter(dir => !EXCLUDES.includes(dir))
|
.filter(dir => !EXCLUDES.includes(dir))
|
||||||
.filter(dir =>
|
.filter(dir =>
|
||||||
ENTRY_EXTS.some(ext => existsSync(join(SRC_DIR, dir, `index.${ext}`)))
|
ENTRY_EXTS.some(ext => {
|
||||||
|
const path = join(SRC_DIR, dir, `index.${ext}`);
|
||||||
|
if (existsSync(path)) {
|
||||||
|
return readFileSync(path, 'utf-8').indexOf('export default') !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user