diff options
author | Vijay A <vraravam@users.noreply.github.com> | 2024-05-19 05:18:05 +0530 |
---|---|---|
committer | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2024-05-19 10:10:59 +0530 |
commit | dd668a67d84ee37cc8a9d39aea2e7b17ef93f317 (patch) | |
tree | 1ffb0f5cb909ac870d2464936a7735e8db1ac756 /scripts | |
parent | fix: whatsapp install desktop notice (#548) (diff) | |
download | ferdium-recipes-dd668a67d84ee37cc8a9d39aea2e7b17ef93f317.tar.gz ferdium-recipes-dd668a67d84ee37cc8a9d39aea2e7b17ef93f317.tar.zst ferdium-recipes-dd668a67d84ee37cc8a9d39aea2e7b17ef93f317.zip |
Handle case correctly where the 'icon.svg' file isn't present
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/package.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/scripts/package.js b/scripts/package.js index a28b01c..0cd36fe 100644 --- a/scripts/package.js +++ b/scripts/package.js | |||
@@ -84,7 +84,7 @@ const compress = (src, dest) => | |||
84 | // Check that each mandatory file exists | 84 | // Check that each mandatory file exists |
85 | for (const file of mandatoryFiles) { | 85 | for (const file of mandatoryFiles) { |
86 | const filePath = path.join(recipeSrc, file); | 86 | const filePath = path.join(recipeSrc, file); |
87 | if (!fs.pathExistsSync(filePath)) { | 87 | if (!fs.existsSync(filePath)) { |
88 | console.log( | 88 | console.log( |
89 | `⚠️ Couldn't package "${recipe}": Folder doesn't contain a "${file}".`, | 89 | `⚠️ Couldn't package "${recipe}": Folder doesn't contain a "${file}".`, |
90 | ); | 90 | ); |
@@ -97,19 +97,21 @@ const compress = (src, dest) => | |||
97 | 97 | ||
98 | // Check icons sizes | 98 | // Check icons sizes |
99 | const svgIcon = path.join(recipeSrc, 'icon.svg'); | 99 | const svgIcon = path.join(recipeSrc, 'icon.svg'); |
100 | const svgSize = sizeOf(svgIcon); | 100 | if (fs.existsSync(svgIcon)) { |
101 | const svgHasRightSize = svgSize.width === svgSize.height; | 101 | const svgSize = sizeOf(svgIcon); |
102 | if (!svgHasRightSize) { | 102 | const svgHasRightSize = svgSize.width === svgSize.height; |
103 | console.log( | 103 | if (!svgHasRightSize) { |
104 | `⚠️ Couldn't package "${recipe}": Recipe SVG icon isn't a square`, | 104 | console.log( |
105 | ); | 105 | `⚠️ Couldn't package "${recipe}": Recipe SVG icon isn't a square`, |
106 | unsuccessful += 1; | 106 | ); |
107 | continue; | 107 | unsuccessful += 1; |
108 | continue; | ||
109 | } | ||
108 | } | 110 | } |
109 | 111 | ||
110 | // Check that user.js does not exist | 112 | // Check that user.js does not exist |
111 | const userJs = path.join(recipeSrc, 'user.js'); | 113 | const userJs = path.join(recipeSrc, 'user.js'); |
112 | if (fs.pathExistsSync(userJs)) { | 114 | if (fs.existsSync(userJs)) { |
113 | console.log( | 115 | console.log( |
114 | `⚠️ Couldn't package "${recipe}": Folder contains a "user.js".`, | 116 | `⚠️ Couldn't package "${recipe}": Folder contains a "user.js".`, |
115 | ); | 117 | ); |
@@ -293,14 +295,14 @@ const compress = (src, dest) => | |||
293 | 295 | ||
294 | if (!config.defaultIcon) { | 296 | if (!config.defaultIcon) { |
295 | // Check if icon.svg exists | 297 | // Check if icon.svg exists |
296 | if (!fs.existsSync(path.join(recipeSrc, 'icon.svg'))) { | 298 | if (!fs.existsSync(svgIcon)) { |
297 | console.log( | 299 | console.log( |
298 | `⚠️ Couldn't package "${recipe}": The recipe doesn't contain a "icon.svg" or "defaultIcon" in package.json`, | 300 | `⚠️ Couldn't package "${recipe}": The recipe doesn't contain a "icon.svg" or "defaultIcon" in package.json`, |
299 | ); | 301 | ); |
300 | unsuccessful += 1; | 302 | unsuccessful += 1; |
301 | } | 303 | } |
302 | 304 | ||
303 | const tempPackage = fs.readJSONSync( | 305 | const tempPackage = fs.readJsonSync( |
304 | path.join(tempFolder, config.id, 'package.json'), | 306 | path.join(tempFolder, config.id, 'package.json'), |
305 | ); | 307 | ); |
306 | tempPackage.defaultIcon = `${repo}${config.id}/icon.svg`; | 308 | tempPackage.defaultIcon = `${repo}${config.id}/icon.svg`; |