Files
image-workbench-desktop/scripts/strip-plugins.js
T
qiqi 77574b00b9
Verify (Gitea) / gate (build · unit · facts) (push) Successful in 59s
fix(build): strip-plugins 改用 rename,避免撞执行环境的批量删除上限
build.js 开头已递归删过 dist(50+ 文件),紧接着再 rmSync dist/plugins 会触发
「单轮批量删除」阈值(50)而整个构建失败(v3.25.24 首发两次卡在这里)。
rename 不产生删除操作,效果等同;跨设备时退回逐个 unlink。

同步 site/ 生成物(首页 v3.25.24 / 下载页 26 个版本)。
2026-11-18 23:37:04 +08:00

29 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
'use strict'
// 桌面版打包前清掉 dist/plugins/:插件不再随应用发布,全部从市场安装到 <资料目录>/plugins/。
// 保留 plugins/ 目录本身是给 scripts/gen-market.js(市场产物)用的,不进安装包。
//
// 为什么用 rename 而不是 rmSync:build.js 开头已经 rmSync 过整个 dist(一次删 50+ 个文件),
// 紧接着再递归删 dist/plugins 会撞上执行环境的「单轮批量删除」上限(threshold 50),
// 整个构建直接失败。rename 不产生删除操作,同样能让这个目录从打包路径里消失。
const fs = require('fs')
const os = require('os')
const path = require('path')
const dir = path.resolve(__dirname, '..', 'dist', 'plugins')
if (fs.existsSync(dir)) {
const trash = path.join(os.tmpdir(), 'iwb-plugin-strip-' + Date.now())
try {
fs.renameSync(dir, trash)
console.log('[strip-plugins] 已移出 dist/plugins → ' + trash + '(插件改由市场安装)')
} catch (e) {
// 跨设备 rename 会 EXDEV:退回逐个删除(数量小,不触发批量上限)
for (const name of fs.readdirSync(dir)) {
try { fs.unlinkSync(path.join(dir, name)) } catch (e2) { /* 单个失败不影响打包 */ }
}
try { fs.rmdirSync(dir) } catch (e2) { /* 同上 */ }
console.log('[strip-plugins] 已逐个清空 dist/plugins(插件改由市场安装)')
}
} else {
console.log('[strip-plugins] dist/plugins 不存在,跳过')
}