@thi.ng/file-io 1.3.0 → 1.3.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/CHANGELOG.md +7 -1
- package/README.md +2 -2
- package/delete.js +1 -1
- package/dir.js +2 -2
- package/file-chunks.js +1 -1
- package/files.js +2 -2
- package/hash.js +2 -2
- package/package.json +7 -7
- package/read.js +1 -1
- package/temp.js +3 -3
- package/text.js +1 -1
- package/watch.d.ts +1 -1
- package/watch.js +2 -2
- package/write.d.ts +1 -1
- package/write.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-02-
|
|
3
|
+
- **Last updated**: 2024-02-22T11:59:16Z
|
|
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.2](https://github.com/thi-ng/umbrella/tree/@thi.ng/file-io@1.3.2) (2024-02-22)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- update all `node:*` imports ([c71a526](https://github.com/thi-ng/umbrella/commit/c71a526))
|
|
17
|
+
|
|
12
18
|
## [1.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/file-io@1.3.0) (2024-02-19)
|
|
13
19
|
|
|
14
20
|
#### 🚀 Features
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
[](https://mastodon.thi.ng/@toxi)
|
|
19
19
|
|
|
20
20
|
> [!NOTE]
|
|
21
|
-
> This is one of
|
|
21
|
+
> This is one of 190 standalone projects, maintained as part
|
|
22
22
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
23
23
|
> and anti-framework.
|
|
24
24
|
>
|
|
@@ -59,7 +59,7 @@ For Node.js REPL:
|
|
|
59
59
|
const fileIo = await import("@thi.ng/file-io");
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 1.
|
|
62
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 1.99 KB
|
|
63
63
|
|
|
64
64
|
## Dependencies
|
|
65
65
|
|
package/delete.js
CHANGED
package/dir.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, statSync } from "fs";
|
|
2
|
-
import { dirname } from "path";
|
|
1
|
+
import { existsSync, mkdirSync, statSync } from "node:fs";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
3
|
const ensureDir = (dir) => dir.length > 0 && !existsSync(dir) ? (mkdirSync(dir, { recursive: true }), true) : false;
|
|
4
4
|
const ensureDirForFile = (path) => ensureDir(dirname(path));
|
|
5
5
|
const isDirectory = (path) => statSync(path).isDirectory();
|
package/file-chunks.js
CHANGED
package/files.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { readdirSync, statSync } from "fs";
|
|
2
|
-
import { sep } from "path";
|
|
1
|
+
import { readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { sep } from "node:path";
|
|
3
3
|
import { isDirectory } from "./dir.js";
|
|
4
4
|
import { __ensurePred } from "./internal/ensure.js";
|
|
5
5
|
const files = (dir, match = "", maxDepth = Infinity, logger) => __files(dir, match, logger, maxDepth, 0);
|
package/hash.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createHash } from "crypto";
|
|
2
|
-
import { readFileSync } from "fs";
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
3
|
const fileHash = (path, logger, algo = "sha256") => {
|
|
4
4
|
const sum = createHash(algo);
|
|
5
5
|
sum.update(readFileSync(path));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/file-io",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Assorted file I/O utils (with logging support) for NodeJS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"test": "bun test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@thi.ng/api": "^8.9.
|
|
39
|
-
"@thi.ng/checks": "^3.
|
|
40
|
-
"@thi.ng/hex": "^2.3.
|
|
41
|
-
"@thi.ng/logger": "^3.0.
|
|
42
|
-
"@thi.ng/random": "^3.6.
|
|
38
|
+
"@thi.ng/api": "^8.9.25",
|
|
39
|
+
"@thi.ng/checks": "^3.5.0",
|
|
40
|
+
"@thi.ng/hex": "^2.3.37",
|
|
41
|
+
"@thi.ng/logger": "^3.0.2",
|
|
42
|
+
"@thi.ng/random": "^3.6.32"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@microsoft/api-extractor": "^7.40.1",
|
|
@@ -120,5 +120,5 @@
|
|
|
120
120
|
"status": "stable",
|
|
121
121
|
"year": 2022
|
|
122
122
|
},
|
|
123
|
-
"gitHead": "
|
|
123
|
+
"gitHead": "4513a1c703bdbf0f0867f03e547e47692e415fac\n"
|
|
124
124
|
}
|
package/read.js
CHANGED
package/temp.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isString } from "@thi.ng/checks/is-string";
|
|
2
2
|
import { randomID } from "@thi.ng/random/random-id";
|
|
3
|
-
import { realpathSync, writeFileSync } from "fs";
|
|
4
|
-
import { tmpdir } from "os";
|
|
5
|
-
import { sep } from "path";
|
|
3
|
+
import { realpathSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { sep } from "node:path";
|
|
6
6
|
import { ensureDirForFile } from "./dir.js";
|
|
7
7
|
const createTempFile = (body, logger, name) => {
|
|
8
8
|
const path = tempFilePath(name);
|
package/text.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isArray } from "@thi.ng/checks/is-array";
|
|
2
|
-
import { readFileSync } from "fs";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
3
|
import { writeFile } from "./write.js";
|
|
4
4
|
const readText = (path, logger, encoding = "utf-8") => {
|
|
5
5
|
logger && logger.debug("reading file:", path);
|
package/watch.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { type Event, type IClear, type INotify, type IObjectOf, type Listener, type Predicate } from "@thi.ng/api";
|
|
3
3
|
import type { ILogger } from "@thi.ng/logger";
|
|
4
|
-
import { type FSWatcher } from "fs";
|
|
4
|
+
import { type FSWatcher } from "node:fs";
|
|
5
5
|
export interface WatcherOpts {
|
|
6
6
|
/**
|
|
7
7
|
* Number of milliseconds between observing a file change and notifying
|
package/watch.js
CHANGED
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
} from "@thi.ng/api";
|
|
15
15
|
import { isString } from "@thi.ng/checks/is-string";
|
|
16
16
|
import { NULL_LOGGER } from "@thi.ng/logger/null";
|
|
17
|
-
import { watch as $watch, existsSync } from "fs";
|
|
18
|
-
import { join } from "path";
|
|
17
|
+
import { watch as $watch, existsSync } from "node:fs";
|
|
18
|
+
import { join } from "node:path";
|
|
19
19
|
import { isDirectory } from "./dir.js";
|
|
20
20
|
import { __ensurePred } from "./internal/ensure.js";
|
|
21
21
|
const EVENT_ADDED = "added";
|
package/write.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { TypedArray } from "@thi.ng/api";
|
|
3
3
|
import type { ILogger } from "@thi.ng/logger";
|
|
4
|
-
import { type WriteFileOptions } from "fs";
|
|
4
|
+
import { type WriteFileOptions } from "node:fs";
|
|
5
5
|
/**
|
|
6
6
|
* Writes `body` as to given `path` (using optional `opts` to define encoding).
|
|
7
7
|
* If `dryRun` is true (default: false), the file WON'T be written, however if a
|
package/write.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isString } from "@thi.ng/checks/is-string";
|
|
2
|
-
import { writeFileSync } from "fs";
|
|
2
|
+
import { writeFileSync } from "node:fs";
|
|
3
3
|
import { ensureDirForFile } from "./dir.js";
|
|
4
4
|
const writeFile = (path, body, opts, logger, dryRun = false) => {
|
|
5
5
|
logger && logger.info(`${dryRun ? "[dryrun] " : ""}writing file: ${path}`);
|