squishjs 1.0.2 → 1.0.4

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": "squishjs",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "squish & unsquish stuff",
5
5
  "scripts": {
6
6
  "test": "node testRunner.js"
package/src/Asset.js CHANGED
@@ -1,8 +1,6 @@
1
1
  const path = require('path');
2
2
  const { getAppDataPath } = require('./utils');
3
3
 
4
- const HG_ASSET_PATH = path.join(getAppDataPath(), 'asset-cache');
5
-
6
4
  class Asset {
7
5
  constructor(info, data = null) {
8
6
  this.info = info;
@@ -72,6 +70,7 @@ class Asset {
72
70
 
73
71
  getFileLocation() {
74
72
  const fileHash = this.getHash(this.info.id);
73
+ const HG_ASSET_PATH = path.join(getAppDataPath(), 'asset-cache');
75
74
  return `${HG_ASSET_PATH}/${fileHash}`;
76
75
  }
77
76
 
@@ -93,6 +92,7 @@ class Asset {
93
92
  }
94
93
 
95
94
  async downloadSync(force) {
95
+ const HG_ASSET_PATH = path.join(getAppDataPath(), 'asset-cache');
96
96
  if (!fs.existsSync(HG_ASSET_PATH)) {
97
97
  fs.mkdirSync(HG_ASSET_PATH);
98
98
  }
@@ -110,6 +110,7 @@ class Asset {
110
110
  }
111
111
 
112
112
  download(force) {
113
+ const HG_ASSET_PATH = path.join(getAppDataPath(), 'asset-cache');
113
114
  if (!this.fs.existsSync(HG_ASSET_PATH)) {
114
115
  this.fs.mkdirSync(HG_ASSET_PATH);
115
116
  }
package/src/utils.js CHANGED
@@ -1,15 +1,19 @@
1
1
  const path = require('path');
2
2
 
3
3
  const getAppDataPath = () => {
4
+ if (!process) {
5
+ return "";
6
+ }
7
+
4
8
  switch (process.platform) {
5
9
  case "darwin": {
6
- return path.join(process.env.HOME, "Library", "Application Support", "Your app name");
10
+ return path.join(process.env.HOME, "Library", "Application Support", "homegames");
7
11
  }
8
12
  case "win32": {
9
- return path.join(process.env.APPDATA, "Your app name");
13
+ return path.join(process.env.APPDATA, "homegames");
10
14
  }
11
15
  case "linux": {
12
- return path.join(process.env.HOME, ".Your app name");
16
+ return path.join(process.env.HOME, ".homegames");
13
17
  }
14
18
  default: {
15
19
  console.log("Unsupported platform!");
@@ -18,29 +22,6 @@ const getAppDataPath = () => {
18
22
  }
19
23
  }
20
24
 
21
-
22
- function saveAppData(content) {
23
- const appDatatDirPath = getAppDataPath();
24
-
25
- // Create appDataDir if not exist
26
- if (!fs.existsSync(appDatatDirPath)) {
27
- fs.mkdirSync(appDatatDirPath);
28
- }
29
-
30
- const appDataFilePath = path.join(appDatatDirPath, 'appData.json');
31
- content = JSON.stringify(content);
32
-
33
- fs.writeFile(appDataFilePath, content, (err) => {
34
- if (err) {
35
- console.log("There was a problem saving data!");
36
- // console.log(err);
37
- } else {
38
- console.log("Data saved correctly!");
39
- loadAppData();
40
- }
41
- });
42
- };
43
-
44
25
  module.exports = {
45
26
  getAppDataPath
46
27
  }