mod-build 4.0.106-beta.1 → 4.0.106-beta.3
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.
package/package.json
CHANGED
|
@@ -99,6 +99,7 @@ async function downloadImage(url) {
|
|
|
99
99
|
// first check if the image already exists in public/assets folder
|
|
100
100
|
const imagePath = path.join(defaultSettings.publicFolder, defaultSettings.assetsSubfolder, url);
|
|
101
101
|
if (fs.existsSync(imagePath)) {
|
|
102
|
+
console.log(`Image ${url} already exists`);
|
|
102
103
|
return null;
|
|
103
104
|
}
|
|
104
105
|
// download the image and put in imagePath
|
|
@@ -106,17 +107,15 @@ async function downloadImage(url) {
|
|
|
106
107
|
const fileUrl = `https://${defaultSettings.nodeEnv}/quote/resources/assets/${url}`
|
|
107
108
|
const response = await fetch(fileUrl);
|
|
108
109
|
if (!response.ok) {
|
|
109
|
-
|
|
110
|
-
throw new Error(`Error downloading image ${url}: ${response.statusText}`);
|
|
110
|
+
throw new Error(`Error downloading image ${fileUrl}: ${response.statusText}`);
|
|
111
111
|
}
|
|
112
112
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
113
113
|
fs.mkdirSync(path.dirname(imagePath), { recursive: true });
|
|
114
114
|
fs.writeFileSync(imagePath, buffer);
|
|
115
|
-
console.log(`Downloaded image ${
|
|
116
|
-
return
|
|
115
|
+
console.log(`Downloaded image ${fileUrl}`);
|
|
116
|
+
return imagePath;
|
|
117
117
|
} catch (error) {
|
|
118
|
-
|
|
119
|
-
throw new Error(`Error downloading image ${url}: ${error}`);
|
|
118
|
+
throw new Error(`Error downloading image ${fileUrl}: ${error}`);
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
|