Skip to content

Commit

Permalink
fix: should check skeleton file existed before read
Browse files Browse the repository at this point in the history
  • Loading branch information
XGHeaven committed Nov 18, 2024
1 parent e14dc87 commit 43210b5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/tidy-dots-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/plugin-miniapp': patch
---

fix: should check skeleton file existed before read
4 changes: 1 addition & 3 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Publish canary

on:
push:
branches:
- release/**
pull_request:

jobs:
canary:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ export default class MiniPlugin {
path: pagePath,
isNative,
stylePath: isNative ? this.getStylePath(pagePath) : undefined,
templatePath: isNative ? this.getTemplatePath(pagePath) : undefined,
skeletonPath: isNative ? this.getSkeletonExtraPath(pagePath) : undefined,
};
}),
Expand Down Expand Up @@ -690,10 +691,10 @@ export default class MiniPlugin {
}
this.addEntry(path.resolve(__dirname, '..', 'template/custom-wrapper'), 'custom-wrapper', META_TYPE.STATIC);

const resolveComponentStyleEntry = (name: string, stylePaths: string[]) => {
const resolveComponentStyleEntry = (name: string, stylePaths: string[], ext = this.options.fileType.style) => {
for (const stylePath of stylePaths) {
if (fs.existsSync(stylePath)) {
this.addEntry(stylePath, this.getTargetFilePath(name, this.options.fileType.style), META_TYPE.NORMAL);
this.addEntry(stylePath, this.getTargetFilePath(name, ext), META_TYPE.NORMAL);
break;
}
}
Expand All @@ -709,12 +710,10 @@ export default class MiniPlugin {
this.addEntry(item.templatePath, this.getTemplatePath(item.name), META_TYPE.NORMAL);
}

if (item.skeletonPath) {
if (item.skeletonPath.template) {
this.addEntry(item.skeletonPath.template, this.getTargetFilePath(item.name, `${this.options.fileType.skeletonMidExt}${this.options.fileType.templ}`), META_TYPE.NORMAL);
}
if (item.skeletonPath && item.skeletonPath.template && fs.existsSync(item.skeletonPath.template)) {
this.addEntry(item.skeletonPath.template, this.getTargetFilePath(item.name, `${this.options.fileType.skeletonMidExt}${this.options.fileType.templ}`), META_TYPE.NORMAL);
if (item.skeletonPath.style) {
resolveComponentStyleEntry(this.getTargetFilePath(item.name, this.options.fileType.skeletonMidExt), item.skeletonPath.style);
resolveComponentStyleEntry(item.name, item.skeletonPath.style, `${this.options.fileType.skeletonMidExt}${this.options.fileType.style}`);
}
}
} else {
Expand Down

0 comments on commit 43210b5

Please sign in to comment.