squishjs 1.0.1 → 1.0.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squishjs",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "squish & unsquish stuff",
5
5
  "scripts": {
6
6
  "test": "node testRunner.js"
package/src/Asset.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const path = require('path');
2
+ const { getAppDataPath } = require('./utils');
2
3
 
3
4
  const HG_ASSET_PATH = path.join(getAppDataPath(), 'asset-cache');
4
5
 
package/src/utils.js ADDED
@@ -0,0 +1,46 @@
1
+ const path = require('path');
2
+
3
+ const getAppDataPath = () => {
4
+ switch (process.platform) {
5
+ case "darwin": {
6
+ return path.join(process.env.HOME, "Library", "Application Support", "Your app name");
7
+ }
8
+ case "win32": {
9
+ return path.join(process.env.APPDATA, "Your app name");
10
+ }
11
+ case "linux": {
12
+ return path.join(process.env.HOME, ".Your app name");
13
+ }
14
+ default: {
15
+ console.log("Unsupported platform!");
16
+ process.exit(1);
17
+ }
18
+ }
19
+ }
20
+
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
+ module.exports = {
45
+ getAppDataPath
46
+ }