xshell 1.0.152 → 1.0.153

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/builder.js +18 -2
  2. package/package.json +1 -1
package/builder.js CHANGED
@@ -530,17 +530,33 @@ export class Bundler {
530
530
  console.log(`复制 ${this.name} 项目文件及依赖 -> ${this.fpd_out}`);
531
531
  if (dependencies)
532
532
  await fmkdir(`${fpd_out}vendors/`, { print: false });
533
+ // 输出路径 -> 原路径,用来保证只复制一次且是同样的映射
534
+ let records = new Map();
535
+ const { name } = this;
533
536
  async function fcopy_asset(asset) {
534
537
  let src, out;
535
538
  if (typeof asset === 'string')
536
539
  src = out = asset;
537
540
  else
538
541
  ({ src, out } = asset);
539
- await fcopy(path.resolve_with_slash(fpd_root, src), `${fpd_out}${out}`, { print: print.files });
542
+ await fcopy_record(path.resolve_with_slash(fpd_root, src), `${fpd_out}${out}`);
543
+ }
544
+ async function fcopy_record(fp_src, fp_out) {
545
+ // 保证同样的输出资源只被写入一次
546
+ const fp_src_old = records.get(fp_out);
547
+ if (fp_src_old) {
548
+ if (fp_src_old === fp_src) { }
549
+ else
550
+ throw new Error(`${name} 复制项目资源冲突, ${fp_src_old} 和 ${fp_src} 均复制到 ${fp_out}`);
551
+ }
552
+ else {
553
+ records.set(fp_out, fp_src);
554
+ await fcopy(fp_src, fp_out, { print: print.files });
555
+ }
540
556
  }
541
557
  await Promise.all([
542
558
  ...this.resolve_dependency_files(dependencies, true, { production })
543
- .map(async (fp) => fcopy(`${fpd_root}node_modules/${fp}`, `${fpd_out}vendors/${fp}`, { print: print.files })),
559
+ .map(async (fp) => fcopy_record(`${fpd_root}node_modules/${fp}`, `${fpd_out}vendors/${fp}`)),
544
560
  ...this.resolve_config(assets, production)
545
561
  .map(fcopy_asset),
546
562
  ...this.htmls ? Object.entries(this.htmls).map(async ([fp_html, { icon, manifest, scripts, mscripts }]) => Promise.all([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xshell",
3
- "version": "1.0.152",
3
+ "version": "1.0.153",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "bin": {