xshell 1.0.151 → 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.
- package/builder.js +19 -3
- package/package.json +1 -1
package/builder.js
CHANGED
|
@@ -527,20 +527,36 @@ export class Bundler {
|
|
|
527
527
|
}
|
|
528
528
|
async copy_files({ dependencies = this.dependencies, production = this.production, assets = this.assets, fpd_root = this.fpd_root, fpd_out = this.fpd_out, print = { info: true, files: false } } = {}) {
|
|
529
529
|
if (print.info)
|
|
530
|
-
console.log(`复制 ${this.name} 项目文件及依赖
|
|
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
|
|
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) =>
|
|
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([
|