squishjs 1.0.11 → 1.1.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Asset.js +5 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squishjs",
3
- "version": "1.0.11",
3
+ "version": "1.1.1",
4
4
  "description": "squish & unsquish stuff",
5
5
  "scripts": {
6
6
  "test": "node testRunner.js"
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;
@@ -157,17 +160,14 @@ class Asset {
157
160
  const filePath = `${path}/${fileHash}`;
158
161
 
159
162
  const writeStream = this.fs.createWriteStream(filePath);
163
+ const getModule = this.https;
160
164
 
161
165
  writeStream.on('close', () => {
162
166
  resolve(filePath);
163
167
  });
164
168
 
165
169
  let data = '';
166
- const assetSource = this.info?.source? || 'https://assets.homegames.io';
167
-
168
- const getModule = assetSource.startsWith('https') ? this.https : this.http;
169
-
170
- getModule.get(`${assetSource}/${assetId}`, (res) => {
170
+ getModule.get(`${ASSET_URL}/${assetId}`, (res) => {
171
171
  res.on('data', (chunk) => {
172
172
  data += chunk;
173
173
  writeStream.write(chunk);