@thi.ng/file-io 1.2.6 → 1.3.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/CHANGELOG.md +7 -1
- package/dir.d.ts +9 -1
- package/dir.js +4 -5
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-02-
|
|
3
|
+
- **Last updated**: 2024-02-19T15:50:26Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
## [1.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/file-io@1.3.0) (2024-02-19)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add ensureDir() ([8ca3085](https://github.com/thi-ng/umbrella/commit/8ca3085))
|
|
17
|
+
|
|
12
18
|
## [1.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/file-io@1.2.0) (2024-01-26)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/dir.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assumes given path is to a directory. Checks if the dir exists and if not
|
|
3
|
+
* attempts to create it and then returns true. Otherwise returns false.
|
|
4
|
+
*
|
|
5
|
+
* @param dir
|
|
6
|
+
*/
|
|
7
|
+
export declare const ensureDir: (dir: string) => boolean;
|
|
1
8
|
/**
|
|
2
9
|
* Checks if the directory for given file `path` already exists, and if not the
|
|
3
10
|
* case, creates it. Returns true if the latter case.
|
|
@@ -10,7 +17,8 @@
|
|
|
10
17
|
*/
|
|
11
18
|
export declare const ensureDirForFile: (path: string) => boolean;
|
|
12
19
|
/**
|
|
13
|
-
* Returns true if `path` is a directory (assumes path exists
|
|
20
|
+
* Returns true if `path` is a directory (assumes path exists, if not throws an
|
|
21
|
+
* error).
|
|
14
22
|
*
|
|
15
23
|
* @param path
|
|
16
24
|
*/
|
package/dir.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, statSync } from "fs";
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
return dir.length > 0 && !existsSync(dir) ? (mkdirSync(dir, { recursive: true }), true) : false;
|
|
6
|
-
};
|
|
2
|
+
import { dirname } from "path";
|
|
3
|
+
const ensureDir = (dir) => dir.length > 0 && !existsSync(dir) ? (mkdirSync(dir, { recursive: true }), true) : false;
|
|
4
|
+
const ensureDirForFile = (path) => ensureDir(dirname(path));
|
|
7
5
|
const isDirectory = (path) => statSync(path).isDirectory();
|
|
8
6
|
export {
|
|
7
|
+
ensureDir,
|
|
9
8
|
ensureDirForFile,
|
|
10
9
|
isDirectory
|
|
11
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/file-io",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Assorted file I/O utils (with logging support) for NodeJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@thi.ng/api": "^8.9.23",
|
|
39
39
|
"@thi.ng/checks": "^3.4.23",
|
|
40
40
|
"@thi.ng/hex": "^2.3.35",
|
|
41
|
-
"@thi.ng/logger": "^
|
|
41
|
+
"@thi.ng/logger": "^3.0.0",
|
|
42
42
|
"@thi.ng/random": "^3.6.30"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"status": "stable",
|
|
121
121
|
"year": 2022
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "ea2ec2e4f14c572bbfac00c43953a6c4033da09e\n"
|
|
124
124
|
}
|