fix: window下vuex插件路径

This commit is contained in:
aringlai 2021-03-04 14:19:37 +08:00
parent 25fffdf08e
commit 5cbb1d5352
2 changed files with 1335 additions and 576 deletions

View File

@ -1,6 +1,6 @@
import { parser } from '@umijs/utils';
import { readdirSync, readFileSync, statSync } from 'fs';
import { join } from 'path';
import { join, sep } from 'path';
/**
* 获取文件夹所有JS文件路径
@ -28,7 +28,7 @@ function getDirFilePaths(dir) {
function pathToHump(path, root) {
return path.replace(root, '')
.replace('.js', '')
.replace(/(\/|\.|-|_)\S/g, text => text[1].toUpperCase())
.replace(RegExp(`(${sep}|\\.|-|_)\\S`, 'g'), text => text[1].toUpperCase())
.replace(/\S/, text => text.toLowerCase());
}
@ -102,7 +102,7 @@ function parseModel(paths = [], root) {
let GETTER_TYPES = {};
paths.forEach((path) => {
const moduleName = pathToHump(path, root);
importModules.push(`import ${moduleName} from '${path}'`);
importModules.push(`import ${moduleName} from '${path.replace(/\\/g, '\\\\')}'`);
modules.push(moduleName);
const content = readFileSync(path).toString('utf-8');
let ast = parser.parse(content, {

1905
yarn.lock

File diff suppressed because it is too large Load Diff