@hypernym/utils 2.0.2 → 2.1.0
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/dist/fs/index.mjs +13 -0
- package/dist/types/fs/index.d.ts +31 -0
- package/package.json +11 -7
- package/dist/node/index.mjs +0 -7
- package/dist/types/node/index.d.ts +0 -6
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { access, constants, mkdir, writeFile as writeFile$1 } from 'node:fs/promises';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
|
|
4
|
+
async function exists(path) {
|
|
5
|
+
return await access(path, constants.F_OK).then(() => true).catch(() => false);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async function writeFile(path, data, options) {
|
|
9
|
+
await mkdir(dirname(path), { recursive: true });
|
|
10
|
+
return await writeFile$1(path, data, options);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { exists, writeFile };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { writeFile as writeFile$1 } from 'node:fs/promises';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the file or directory exists.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* // New import
|
|
10
|
+
* import { exists } from '@hypernym/utils/fs'
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* // Deprecated import
|
|
15
|
+
* import { exists } from '@hypernym/utils/node'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare function exists(path: string): Promise<boolean>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Writes data to a file recursively.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
*
|
|
25
|
+
* ```ts
|
|
26
|
+
* import { writeFile } from '@hypernym/utils/fs'
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
declare function writeFile(path: string, data: Parameters<typeof writeFile$1>[1], options?: Parameters<typeof writeFile$1>[2]): Promise<void>;
|
|
30
|
+
|
|
31
|
+
export { exists, writeFile };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypernym/utils",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"author": "Hypernym Studio",
|
|
5
5
|
"description": "A collection of reusable utilities.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,9 +13,13 @@
|
|
|
13
13
|
"types": "./dist/types/index.d.ts",
|
|
14
14
|
"import": "./dist/index.mjs"
|
|
15
15
|
},
|
|
16
|
+
"./fs": {
|
|
17
|
+
"types": "./dist/types/fs/index.d.ts",
|
|
18
|
+
"import": "./dist/fs/index.mjs"
|
|
19
|
+
},
|
|
16
20
|
"./node": {
|
|
17
|
-
"types": "./dist/types/
|
|
18
|
-
"import": "./dist/
|
|
21
|
+
"types": "./dist/types/fs/index.d.ts",
|
|
22
|
+
"import": "./dist/fs/index.mjs"
|
|
19
23
|
}
|
|
20
24
|
},
|
|
21
25
|
"files": [
|
|
@@ -36,7 +40,7 @@
|
|
|
36
40
|
"scripts": {
|
|
37
41
|
"dev": "vite playgrounds/client",
|
|
38
42
|
"dev:node": "vite-node -w playgrounds/node/main.ts",
|
|
39
|
-
"build": "
|
|
43
|
+
"build": "hyperbundler",
|
|
40
44
|
"test:types": "vitest -c .config/vitest.config.ts typecheck",
|
|
41
45
|
"lint": "ESLINT_USE_FLAT_CONFIG=true eslint -c .config/eslint.config.js .",
|
|
42
46
|
"lint:fix": "ESLINT_USE_FLAT_CONFIG=true eslint -c .config/eslint.config.js --fix .",
|
|
@@ -44,13 +48,13 @@
|
|
|
44
48
|
"prepublishOnly": "npm run build"
|
|
45
49
|
},
|
|
46
50
|
"devDependencies": {
|
|
51
|
+
"@hypernym/bundler": "^0.1.2",
|
|
47
52
|
"@hypernym/eslint-config": "^2.0.1",
|
|
48
53
|
"@hypernym/prettier-config": "^2.0.1",
|
|
49
54
|
"@hypernym/tsconfig": "^1.1.0",
|
|
50
|
-
"@types/node": "^20.8.
|
|
51
|
-
"eslint": "^8.
|
|
55
|
+
"@types/node": "^20.8.4",
|
|
56
|
+
"eslint": "^8.51.0",
|
|
52
57
|
"prettier": "^3.0.3",
|
|
53
|
-
"rolli": "^0.7.0",
|
|
54
58
|
"typescript": "^5.2.2",
|
|
55
59
|
"vitest": "^0.34.6"
|
|
56
60
|
}
|
package/dist/node/index.mjs
DELETED