ohos-router 1.1.7 → 1.1.8

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/package.json +1 -1
  2. package/router.ts +11 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ohos-router",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "鸿蒙路由管理插件",
5
5
  "main": "main.js",
6
6
  "scripts": {
package/router.ts CHANGED
@@ -451,13 +451,18 @@ function printBuildProFile(buildProfileData: string, type: number) {
451
451
  " ],\n"
452
452
  buildProfileContent = insertString(buildProfileData, buildProfilePosition, buildProfileBuilder)
453
453
  } else if (type == 3) {
454
- let buildProfileBean = JSON.parse(buildProfileData)
455
- buildProfileBean.buildOption.arkOptions.runtimeOnly.packages = [];
456
- let endJson = JSON.stringify(buildProfileBean)
454
+ let buildProfileBean = JSON.parse(buildProfileData);
455
+ let packages = buildProfileBean.buildOption.arkOptions.runtimeOnly.packages;
456
+ const mergedArray: number[] = [...dependenciesKey, ...packages].reduce(
457
+ (unique: number[], item: number) => {
458
+ return unique.includes(item) ? unique : [...unique, item];
459
+ },
460
+ []
461
+ );
457
462
  let buildProfileTag = "\"packages\": ["
458
- let buildProfilePosition = endJson.indexOf(buildProfileTag) + buildProfileTag.length
459
- let buildProfileBuilder = "\n" + endArray
460
- buildProfileContent = insertString(endJson, buildProfilePosition, buildProfileBuilder)
463
+ let buildProfilePosition = buildProfileData.indexOf(buildProfileTag) + buildProfileTag.length
464
+ let buildProfileBuilder = "\n" + mergedArray
465
+ buildProfileContent = insertString(buildProfileData, buildProfilePosition, buildProfileBuilder)
461
466
  }
462
467
 
463
468
  FileUtil.writeFileSync(buildProfilePath, buildProfileContent);