squishjs 1.1.0 → 1.1.2
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 +1 -1
- package/src/Asset.js +11 -8
package/package.json
CHANGED
package/src/Asset.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const { getAppDataPath } = require('./utils');
|
|
3
3
|
|
|
4
|
+
// assets is the old stuff, save it for backward compatibility
|
|
5
|
+
const ASSET_URL = process.env.API_URL ? `${process.env.API_URL}/assets`: 'https://assets.homegames.io';
|
|
6
|
+
|
|
4
7
|
class Asset {
|
|
5
8
|
constructor(info, data = null) {
|
|
6
9
|
this.info = info;
|
|
@@ -163,16 +166,15 @@ class Asset {
|
|
|
163
166
|
resolve(filePath);
|
|
164
167
|
});
|
|
165
168
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
data += chunk;
|
|
170
|
-
writeStream.write(chunk);
|
|
171
|
-
});
|
|
172
|
-
res.on('end', () => {
|
|
173
|
-
writeStream.end();
|
|
169
|
+
getModule.get(`${ASSET_URL}/${assetId}`, (res) => {
|
|
170
|
+
writeStream.on('finish', () => {
|
|
171
|
+
writeStream.close();
|
|
174
172
|
});
|
|
173
|
+
|
|
174
|
+
res.pipe(writeStream);
|
|
175
175
|
}).on('error', error => {
|
|
176
|
+
console.error('Failed to download asset');
|
|
177
|
+
console.error(error);
|
|
176
178
|
reject(error);
|
|
177
179
|
});
|
|
178
180
|
});
|
|
@@ -181,3 +183,4 @@ class Asset {
|
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
module.exports = Asset;
|
|
186
|
+
|