@catladder/cli 2.0.0 → 2.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
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "2.0.0",
56
+ "version": "2.0.2",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -1,7 +1,6 @@
1
- import fs from "fs-extra";
1
+ import { readFile as fsExtraReadFile } from "fs-extra";
2
2
 
3
- const readFile = async (file: string) =>
4
- fs.readFile(file, { encoding: "utf-8" });
3
+ const readFile = (file: string) => fsExtraReadFile(file, { encoding: "utf-8" });
5
4
 
6
5
  export const readFileOrError = async (filePath: string) => {
7
6
  try {
@@ -1,4 +1,4 @@
1
- import fs from "fs-extra";
1
+ import { createFile, pathExists, readFile, writeFile } from "fs-extra";
2
2
  import { homedir } from "os";
3
3
 
4
4
  import { parse, stringify } from "yaml";
@@ -6,11 +6,13 @@ const directory = `${homedir()}/.catladder`;
6
6
  const file = `${directory}/preferences.yml`;
7
7
 
8
8
  const getPreferences = async () => {
9
- if (!(await fs.pathExists(file))) {
10
- await fs.createFile(file);
9
+ if (!(await pathExists(file))) {
10
+ await createFile(file);
11
11
  }
12
- return (parse(await fs.readFile(file, { encoding: "utf-8" })) ??
13
- {}) as Record<string, string>;
12
+ return (parse(await readFile(file, { encoding: "utf-8" })) ?? {}) as Record<
13
+ string,
14
+ string
15
+ >;
14
16
  };
15
17
 
16
18
  export const hasPreference = async (key: string) => {
@@ -30,5 +32,5 @@ export const setPreference = async (key: string, value: string | number) => {
30
32
  [key]: value,
31
33
  };
32
34
 
33
- await fs.writeFile(file, stringify(newPreferences));
35
+ await writeFile(file, stringify(newPreferences));
34
36
  };