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 +1 -1
- package/src/Asset.js +1 -0
- package/src/utils.js +46 -0
package/package.json
CHANGED
package/src/Asset.js
CHANGED
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
|
+
}
|