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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "4.0.106-beta.1",
3
+ "version": "4.0.106-beta.3",
4
4
  "description": "Share components for S3 sites.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -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
- console.error(`Error downloading image ${url}: ${response.statusText}`);
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 ${url} and added to gitignore`);
116
- return path.dirname(imagePath);
115
+ console.log(`Downloaded image ${fileUrl}`);
116
+ return imagePath;
117
117
  } catch (error) {
118
- console.error(`Error downloading image ${url}: ${error}`);
119
- throw new Error(`Error downloading image ${url}: ${error}`);
118
+ throw new Error(`Error downloading image ${fileUrl}: ${error}`);
120
119
  }
121
120
  }
122
121