Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
make json minified
Browse files Browse the repository at this point in the history
  • Loading branch information
DonovanDMC committed Dec 28, 2020
1 parent 3a67ba2 commit 4a1a0b3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "e621downloader.js",
"version": "1.0.21",
"version": "1.0.22",
"description": "",
"main": "build/src/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/util/CacheManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class CacheManager {
data: d! ?? []
};
const fd = fs.openSync(this.file, "r+");
fs.writeFileSync(fd, JSON.stringify(o, null, "\t"));
fs.writeFileSync(fd, JSON.stringify(o));
fs.fsyncSync(fd);
fs.closeSync(fd);
}
Expand Down Expand Up @@ -92,7 +92,7 @@ export default class CacheManager {
c.data = this.unique(...c.data);
if (JSON.stringify(c) === JSON.stringify(o)) return; // don't touch the file if we don't need to
const fd = fs.openSync(this.file, "r+");
fs.writeFileSync(fd, JSON.stringify(c, null, "\t"));
fs.writeFileSync(fd, JSON.stringify(c));
fs.fsyncSync(fd);
fs.closeSync(fd);
}
Expand Down
8 changes: 8 additions & 0 deletions test/sort.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as fs from "fs-extra";
import { Cache } from "../src/util/CacheManager";

const v: Cache = fs.readJSONSync("/home/donovan/Documents/E621Downloader/cache.json");

v.data = v.data.sort((a, b) => (a.tags[0] as any) - (b.tags[0] as any));

fs.writeJSONSync("/home/donovan/Documents/E621Downloader/cache.json", v);

0 comments on commit 4a1a0b3

Please sign in to comment.