diff options
Diffstat (limited to 'scripts/package.js')
-rw-r--r-- | scripts/package.js | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/scripts/package.js b/scripts/package.js index a679c4e..c07f893 100644 --- a/scripts/package.js +++ b/scripts/package.js | |||
@@ -65,29 +65,24 @@ const compress = (src, dest) => | |||
65 | 65 | ||
66 | for (let recipe of availableRecipes) { | 66 | for (let recipe of availableRecipes) { |
67 | const recipeSrc = path.join(recipesFolder, recipe); | 67 | const recipeSrc = path.join(recipesFolder, recipe); |
68 | const packageJson = path.join(recipeSrc, 'package.json'); | 68 | const mandatoryFiles = ['package.json', 'icon.svg']; |
69 | 69 | ||
70 | // Check that package.json exists | 70 | // Check that each mandatory file exists |
71 | if (!(await fs.pathExists(packageJson))) { | 71 | for (let file of mandatoryFiles) { |
72 | console.log( | 72 | const filePath = path.join(recipeSrc, file); |
73 | `⚠️ Couldn't package "${recipe}": Folder doesn't contain a "package.json".`, | 73 | if (!(await fs.pathExists(filePath))) { |
74 | ); | 74 | console.log( |
75 | unsuccessful++; | 75 | `⚠️ Couldn't package "${recipe}": Folder doesn't contain a "${file}".`, |
76 | continue; | 76 | ); |
77 | unsuccessful++; | ||
78 | } | ||
77 | } | 79 | } |
78 | 80 | if (unsuccessful > 0) { | |
79 | // Check that icons exist | ||
80 | const svgIcon = path.join(recipeSrc, 'icon.svg'); | ||
81 | const hasSvg = await fs.pathExists(svgIcon); | ||
82 | if (!hasSvg) { | ||
83 | console.log( | ||
84 | `⚠️ Couldn't package "${recipe}": Recipe doesn't contain an icon SVG`, | ||
85 | ); | ||
86 | unsuccessful++; | ||
87 | continue; | 81 | continue; |
88 | } | 82 | } |
89 | 83 | ||
90 | // Check icons sizes | 84 | // Check icons sizes |
85 | const svgIcon = path.join(recipeSrc, 'icon.svg'); | ||
91 | const svgSize = sizeOf(svgIcon); | 86 | const svgSize = sizeOf(svgIcon); |
92 | const svgHasRightSize = svgSize.width === svgSize.height; | 87 | const svgHasRightSize = svgSize.width === svgSize.height; |
93 | if (!svgHasRightSize) { | 88 | if (!svgHasRightSize) { |
@@ -109,6 +104,7 @@ const compress = (src, dest) => | |||
109 | } | 104 | } |
110 | 105 | ||
111 | // Read package.json | 106 | // Read package.json |
107 | const packageJson = path.join(recipeSrc, 'package.json'); | ||
112 | const config = await fs.readJson(packageJson); | 108 | const config = await fs.readJson(packageJson); |
113 | 109 | ||
114 | // Make sure it contains all required fields | 110 | // Make sure it contains all required fields |
@@ -293,9 +289,9 @@ const compress = (src, dest) => | |||
293 | 289 | ||
294 | // Sort package list alphabetically | 290 | // Sort package list alphabetically |
295 | recipeList = recipeList.sort((a, b) => { | 291 | recipeList = recipeList.sort((a, b) => { |
296 | var textA = a.id.toLowerCase(); | 292 | let textA = a.id.toLowerCase(); |
297 | var textB = b.id.toLowerCase(); | 293 | let textB = b.id.toLowerCase(); |
298 | return textA < textB ? -1 : textA > textB ? 1 : 0; | 294 | return textA < textB ? -1 : (textA > textB ? 1 : 0); |
299 | }); | 295 | }); |
300 | await fs.writeJson(allJson, recipeList, { | 296 | await fs.writeJson(allJson, recipeList, { |
301 | spaces: 2, | 297 | spaces: 2, |