mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
23 lines
678 B
JavaScript
23 lines
678 B
JavaScript
import { glob, winPath } from '@fesjs/utils';
|
||
import { join, basename } from 'path';
|
||
|
||
export function getLocales(cwd) {
|
||
const files = glob
|
||
.sync('*.js', {
|
||
cwd,
|
||
})
|
||
.filter((file) => !file.endsWith('.d.ts') && !file.endsWith('.test.js') && !file.endsWith('.test.jsx'))
|
||
.map((fileName) => {
|
||
const locale = basename(fileName, '.js');
|
||
const importName = locale.replace('-', '');
|
||
return {
|
||
importName,
|
||
locale,
|
||
// import语法的路径,必须处理win
|
||
path: winPath(join(cwd, fileName)),
|
||
};
|
||
});
|
||
|
||
return files;
|
||
}
|