Skip to content

Commit 9baa9a6

Browse files
committed
chore: support windows
1 parent 7728920 commit 9baa9a6

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

packages/tdesign-uniapp/example/script/release/config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@ const path = require('path');
33
const PACKAGES_ROOT = path.resolve(__dirname, '../../../../');
44
const PROJECT_ROOT = path.resolve(PACKAGES_ROOT, '../');
55

6+
// 将 Windows 的 \ 路径分隔符转为 /,确保 glob pattern 跨平台兼容
7+
function toGlobPattern(p) {
8+
return p.split(path.sep).join('/');
9+
}
10+
611
const config = {
712
targetDir: path.resolve(PACKAGES_ROOT, 'tdesign-uniapp/dist'),
813
sourceDir: path.resolve(PACKAGES_ROOT, 'uniapp-components'),
9-
sourceGlob: path.resolve(PACKAGES_ROOT, 'uniapp-components/**/*'),
14+
sourceGlob: toGlobPattern(path.resolve(PACKAGES_ROOT, 'uniapp-components/**/*')),
1015

1116
chatTargetDir: path.resolve(PACKAGES_ROOT, 'tdesign-uniapp-chat/dist'),
1217
chatSourceDir: path.resolve(PACKAGES_ROOT, 'uniapp-pro-components/chat'),
13-
chatSourceGlob: path.resolve(PACKAGES_ROOT, 'uniapp-pro-components/chat/**/*'),
18+
chatSourceGlob: toGlobPattern(path.resolve(PACKAGES_ROOT, 'uniapp-pro-components/chat/**/*')),
1419

1520
demoDir: path.resolve(__dirname, '../../src/pages-more'),
1621
};
@@ -25,4 +30,5 @@ module.exports = {
2530
PACKAGES_ROOT,
2631
PROJECT_ROOT,
2732
DIST_BLACK_LIST,
33+
toGlobPattern,
2834
};

packages/tdesign-uniapp/example/script/release/core.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ async function copy({
88
filePath,
99
config,
1010
}) {
11-
const isDemo = relativePath.split(path.sep)[1] === '_example';
11+
// 兼容 Windows:glob 返回 / 分隔的路径,统一用 / 分割
12+
const normalizedRelativePath = relativePath.split(path.sep).join('/');
13+
const isDemo = normalizedRelativePath.split('/')[1] === '_example';
1214

1315
let targetPath = path.resolve(config.targetDir, relativePath);
1416

1517
if (isDemo && config.demoDir) {
16-
targetPath = path.resolve(config.demoDir, relativePath.replace(`${path.sep}_example`, ''));
18+
targetPath = path.resolve(config.demoDir, relativePath.replace(`${path.sep}_example`, '').replace('/_example', ''));
1719
}
1820

1921
fs.mkdirSync(path.dirname(targetPath), { recursive: true });

packages/tdesign-uniapp/example/script/watch/config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path');
2-
const { PACKAGES_ROOT } = require('../release/config');
2+
const { PACKAGES_ROOT, toGlobPattern } = require('../release/config');
33

44
const VUE3_CLI_ROOT = path.resolve(__dirname, '../..');
55
const APP_ROOT = path.resolve(__dirname, '../../../app');
@@ -37,11 +37,11 @@ const config = {
3737
sourceDir: path.resolve(PACKAGES_ROOT, 'uniapp-components'),
3838
chatSourceDir: path.resolve(PACKAGES_ROOT, 'uniapp-pro-components/chat'),
3939

40-
sourceGlob: path.resolve(PACKAGES_ROOT, 'uniapp-components/**/*'),
41-
chatSourceGlob: path.resolve(PACKAGES_ROOT, 'uniapp-pro-components/chat/**/*'),
42-
baseAndChatSourceGlob: path.resolve(PACKAGES_ROOT, '{uniapp-components,uniapp-pro-components}/**/*'),
40+
sourceGlob: toGlobPattern(path.resolve(PACKAGES_ROOT, 'uniapp-components/**/*')),
41+
chatSourceGlob: toGlobPattern(path.resolve(PACKAGES_ROOT, 'uniapp-pro-components/chat/**/*')),
42+
baseAndChatSourceGlob: toGlobPattern(path.resolve(PACKAGES_ROOT, '{uniapp-components,uniapp-pro-components}/**/*')),
4343

44-
demoPagesGlob: path.resolve(VUE3_CLI_ROOT, 'src/{pages,components,mixins,style}/**/*'),
44+
demoPagesGlob: toGlobPattern(path.resolve(VUE3_CLI_ROOT, 'src/{pages,components,mixins,style}/**/*')),
4545
};
4646

4747

0 commit comments

Comments
 (0)