Skip to content

Commit

Permalink
Merge pull request #26 from obytes/fix-error-andoroid-build
Browse files Browse the repository at this point in the history
fix: add try catch to prevent error on android build phase
  • Loading branch information
SihamBen authored Aug 16, 2023
2 parents 416d2e2 + 572ab20 commit 1690a94
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ node_modules/
assets/*.*.png
example/*.*.png
dist
app.plugin.js
.DS_Store
1 change: 1 addition & 0 deletions app.plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/app.plugin.js');
55 changes: 29 additions & 26 deletions app.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,37 @@ type Params = {
function withIconBadge(config: any, { badges, enabled = true }: Params) {
if (!enabled) return config;

// get source paths from config
const iconPath = config?.icon;
const adaptiveIconPath = config?.android?.adaptiveIcon?.foregroundImage;
// TODO: add more checks for the config object
try {
// get source paths from config
const iconPath = config?.icon;
const adaptiveIconPath = config?.android?.adaptiveIcon?.foregroundImage;
// TODO: add more checks for the config object

// Generate icon with badge
// normally addBadge is async but we don't need to wait for it also not sure how to use async in this context
if (iconPath) {
addBadge({
icon: iconPath,
dstPath: DST_ICON,
badges,
});
config.icon = DST_ICON;
}
// Generate icon with badge
// normally addBadge is async but we don't need to wait for it also not sure how to use async in this context
if (iconPath) {
addBadge({
icon: iconPath,
dstPath: DST_ICON,
badges,
});
config.icon = DST_ICON;
}

// waiting for the adaptive icon support here
if (adaptiveIconPath) {
addBadge({
isAdaptiveIcon: true,
icon: adaptiveIconPath,
dstPath: DST_ADAPTIVE_APP_ICON,
badges,
});
config.android.adaptiveIcon.foregroundImage = DST_ADAPTIVE_APP_ICON;
}
// waiting for the adaptive icon support here
if (adaptiveIconPath) {
addBadge({
isAdaptiveIcon: true,
icon: adaptiveIconPath,
dstPath: DST_ADAPTIVE_APP_ICON,
badges,
});
config.android.adaptiveIcon.foregroundImage = DST_ADAPTIVE_APP_ICON;
}

return config;
return config;
} catch (error) {
return config;
}
}
module.exports = withIconBadge;
// TODO: Add More TYPING for the config object
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"app.plugin.js"
],
"scripts": {
"build": "tsup index.ts --format cjs,esm --dts && cp -r assets dist && tsup app.plugin.ts --format cjs && mv dist/app.plugin.js . && tsup cli/cli.ts",
"build": "tsup index.ts --format cjs,esm --dts && cp -r assets dist && tsup app.plugin.ts --format cjs && tsup cli/cli.ts",
"start": "nodemon --exec ts-node --files example/index.ts",
"start-cli": "nodemon --exec ts-node --files cli/cli.ts",
"type-check": "tsc --noEmit",
Expand Down

0 comments on commit 1690a94

Please sign in to comment.