path-class 0.6.0 → 0.7.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/lib/path-class/Path.d.ts +155 -0
- package/dist/lib/path-class/chunks/chunk-KSCIGSNU.js +317 -0
- package/dist/lib/path-class/chunks/chunk-KSCIGSNU.js.map +7 -0
- package/dist/lib/path-class/index.d.ts +1 -138
- package/dist/lib/path-class/index.js +7 -291
- package/dist/lib/path-class/index.js.map +3 -3
- package/dist/lib/path-class/sync/index.d.ts +57 -0
- package/dist/lib/path-class/sync/index.js +109 -0
- package/dist/lib/path-class/sync/index.js.map +7 -0
- package/dist/lib/path-class/sync/static.d.ts +6 -0
- package/package.json +5 -1
- package/src/{index.test.ts → Path.test.ts} +46 -18
- package/src/Path.ts +446 -0
- package/src/index.ts +1 -415
- package/src/sync/index.ts +235 -0
- package/src/sync/static.ts +14 -0
- package/src/sync/sync.test.ts +191 -0
|
@@ -1,295 +1,11 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
1
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
readFile,
|
|
8
|
-
rename,
|
|
9
|
-
rm,
|
|
10
|
-
stat,
|
|
11
|
-
writeFile
|
|
12
|
-
} from "node:fs/promises";
|
|
13
|
-
import { homedir, tmpdir } from "node:os";
|
|
14
|
-
import { basename, dirname, extname, join } from "node:path";
|
|
15
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
16
|
-
import { xdgCache, xdgConfig, xdgData, xdgState } from "xdg-basedir";
|
|
17
|
-
var Path = class _Path {
|
|
18
|
-
// @ts-expect-error ts(2564): False positive. https://github.com/microsoft/TypeScript/issues/32194
|
|
19
|
-
#path;
|
|
20
|
-
/**
|
|
21
|
-
* If `path` is a string starting with `file:///`, it will be parsed as a file URL.
|
|
22
|
-
*/
|
|
23
|
-
constructor(path) {
|
|
24
|
-
this.#setNormalizedPath(_Path.#pathlikeToString(path));
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Similar to `new URL(path, base)`, but accepting and returning `Path` objects.
|
|
28
|
-
* Note that `base` must be one of:
|
|
29
|
-
*
|
|
30
|
-
* - a valid second argument to `new URL(…)`.
|
|
31
|
-
* - a `Path` representing an absolute path.
|
|
32
|
-
*
|
|
33
|
-
*/
|
|
34
|
-
static resolve(path, base) {
|
|
35
|
-
const baseURL = (() => {
|
|
36
|
-
if (!(base instanceof _Path)) {
|
|
37
|
-
return base;
|
|
38
|
-
}
|
|
39
|
-
if (!base.isAbsolutePath()) {
|
|
40
|
-
throw new Error(
|
|
41
|
-
"The `base` arg to `Path.resolve(\u2026)` must be an absolute path."
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
return pathToFileURL(base.#path);
|
|
45
|
-
})();
|
|
46
|
-
return new _Path(new URL(_Path.#pathlikeToString(path), baseURL));
|
|
47
|
-
}
|
|
48
|
-
static #pathlikeToString(path) {
|
|
49
|
-
if (path instanceof _Path) {
|
|
50
|
-
return path.#path;
|
|
51
|
-
}
|
|
52
|
-
if (path instanceof URL) {
|
|
53
|
-
return fileURLToPath(path);
|
|
54
|
-
}
|
|
55
|
-
if (typeof path === "string") {
|
|
56
|
-
if (path.startsWith("file:///")) {
|
|
57
|
-
return fileURLToPath(path);
|
|
58
|
-
}
|
|
59
|
-
return path;
|
|
60
|
-
}
|
|
61
|
-
throw new Error("Invalid path");
|
|
62
|
-
}
|
|
63
|
-
#setNormalizedPath(path) {
|
|
64
|
-
this.#path = join(path);
|
|
65
|
-
}
|
|
66
|
-
isAbsolutePath() {
|
|
67
|
-
return this.#path.startsWith("/");
|
|
68
|
-
}
|
|
69
|
-
toFileURL() {
|
|
70
|
-
if (!this.isAbsolutePath()) {
|
|
71
|
-
throw new Error(
|
|
72
|
-
"Tried to convert to file URL when the path is not absolute."
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
return pathToFileURL(this.#path);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* The `Path` can have a trailing slash, indicating that it represents a
|
|
79
|
-
* directory. (If there is no trailing slash, it can represent either a file
|
|
80
|
-
* or a directory.)
|
|
81
|
-
*
|
|
82
|
-
* Some operations will refuse to treat a directory path as a file path. This
|
|
83
|
-
* function identifies such paths.
|
|
84
|
-
*/
|
|
85
|
-
hasTrailingSlash() {
|
|
86
|
-
return this.#path.endsWith("/");
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Same as `.toString()`, but more concise.
|
|
90
|
-
*/
|
|
91
|
-
get path() {
|
|
92
|
-
return this.#path;
|
|
93
|
-
}
|
|
94
|
-
toString() {
|
|
95
|
-
return this.#path;
|
|
96
|
-
}
|
|
97
|
-
/** Constructs a new path by appending the given path segments.
|
|
98
|
-
* This follows `node` semantics for absolute paths: leading slashes in the given descendant segments are ignored.
|
|
99
|
-
*/
|
|
100
|
-
join(...segments) {
|
|
101
|
-
const segmentStrings = segments.map(
|
|
102
|
-
(segment) => segment instanceof _Path ? segment.path : segment
|
|
103
|
-
);
|
|
104
|
-
return new _Path(join(this.#path, ...segmentStrings));
|
|
105
|
-
}
|
|
106
|
-
extendBasename(suffix) {
|
|
107
|
-
const joinedSuffix = join(suffix);
|
|
108
|
-
if (joinedSuffix !== basename(joinedSuffix)) {
|
|
109
|
-
throw new Error("Invalid suffix to extend file name.");
|
|
110
|
-
}
|
|
111
|
-
return new _Path(this.#path + joinedSuffix);
|
|
112
|
-
}
|
|
113
|
-
get parent() {
|
|
114
|
-
return new _Path(dirname(this.#path));
|
|
115
|
-
}
|
|
116
|
-
// Normally I'd stick with `node`'s name, but I think `.dirname` is a
|
|
117
|
-
// particularly poor name. So we support `.dirname` for discovery but mark it
|
|
118
|
-
// as deprecated, even if it will never be removed.
|
|
119
|
-
/** @deprecated Alias for `.parent`. */
|
|
120
|
-
get dirname() {
|
|
121
|
-
return this.parent;
|
|
122
|
-
}
|
|
123
|
-
get basename() {
|
|
124
|
-
return new _Path(basename(this.#path));
|
|
125
|
-
}
|
|
126
|
-
get extension() {
|
|
127
|
-
this.#mustNotHaveTrailingSlash();
|
|
128
|
-
return extname(this.#path);
|
|
129
|
-
}
|
|
130
|
-
// Normally I'd stick with `node`'s name, but I think `.extname` is a
|
|
131
|
-
// particularly poor name. So we support `.extname` for discovery but mark it
|
|
132
|
-
// as deprecated, even if it will never be removed.
|
|
133
|
-
/** @deprecated Alias for `.extension`. */
|
|
134
|
-
get extname() {
|
|
135
|
-
return this.extension;
|
|
136
|
-
}
|
|
137
|
-
#mustNotHaveTrailingSlash() {
|
|
138
|
-
if (this.hasTrailingSlash()) {
|
|
139
|
-
throw new Error(
|
|
140
|
-
"Path ends with a slash, which cannot be treated as a file."
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
async exists(constraints) {
|
|
145
|
-
let stats;
|
|
146
|
-
try {
|
|
147
|
-
stats = await stat(this.#path);
|
|
148
|
-
} catch (e) {
|
|
149
|
-
if (e.code === "ENOENT") {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
throw e;
|
|
153
|
-
}
|
|
154
|
-
if (!constraints?.mustBe) {
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
switch (constraints?.mustBe) {
|
|
158
|
-
case "file": {
|
|
159
|
-
this.#mustNotHaveTrailingSlash();
|
|
160
|
-
if (stats.isFile()) {
|
|
161
|
-
return true;
|
|
162
|
-
}
|
|
163
|
-
throw new Error(`Path exists but is not a file: ${this.#path}`);
|
|
164
|
-
}
|
|
165
|
-
case "directory": {
|
|
166
|
-
if (stats.isDirectory()) {
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
throw new Error(`Path exists but is not a directory: ${this.#path}`);
|
|
170
|
-
}
|
|
171
|
-
default: {
|
|
172
|
-
throw new Error("Invalid path type constraint");
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
async existsAsFile() {
|
|
177
|
-
return this.exists({ mustBe: "file" });
|
|
178
|
-
}
|
|
179
|
-
async existsAsDir() {
|
|
180
|
-
return this.exists({ mustBe: "directory" });
|
|
181
|
-
}
|
|
182
|
-
// I don't think `mkdir` is a great name, but it does match the
|
|
183
|
-
// well-established canonical commandline name. So in this case we keep the
|
|
184
|
-
// awkward abbreviation.
|
|
185
|
-
/** Defaults to `recursive: true`. */
|
|
186
|
-
async mkdir(options) {
|
|
187
|
-
const optionsObject = (() => {
|
|
188
|
-
if (typeof options === "string" || typeof options === "number") {
|
|
189
|
-
return { mode: options };
|
|
190
|
-
}
|
|
191
|
-
return options ?? {};
|
|
192
|
-
})();
|
|
193
|
-
await mkdir(this.#path, { recursive: true, ...optionsObject });
|
|
194
|
-
return this;
|
|
195
|
-
}
|
|
196
|
-
// TODO: check idempotency semantics when the destination exists and is a folder.
|
|
197
|
-
/** Returns the destination path. */
|
|
198
|
-
async cp(destination, options) {
|
|
199
|
-
await cp(this.#path, new _Path(destination).#path, options);
|
|
200
|
-
return new _Path(destination);
|
|
201
|
-
}
|
|
202
|
-
// TODO: check idempotency semantics when the destination exists and is a folder.
|
|
203
|
-
async rename(destination) {
|
|
204
|
-
await rename(this.#path, new _Path(destination).#path);
|
|
205
|
-
}
|
|
206
|
-
/** Create a temporary dir inside the global temp dir for the current user. */
|
|
207
|
-
static async makeTempDir(prefix) {
|
|
208
|
-
return new _Path(
|
|
209
|
-
await mkdtemp(new _Path(tmpdir()).join(prefix ?? "js-temp-").toString())
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
async rm(options) {
|
|
213
|
-
await rm(this.#path, options);
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Equivalent to:
|
|
217
|
-
*
|
|
218
|
-
* .rm({ recursive: true, force: true, ...(options ?? {}) })
|
|
219
|
-
*
|
|
220
|
-
*/
|
|
221
|
-
async rm_rf(options) {
|
|
222
|
-
await this.rm({ recursive: true, force: true, ...options ?? {} });
|
|
223
|
-
}
|
|
224
|
-
read = (options) => (
|
|
225
|
-
// biome-ignore lint/suspicious/noExplicitAny: Needed to wrangle the types.
|
|
226
|
-
readFile(this.#path, options)
|
|
227
|
-
);
|
|
228
|
-
async readText() {
|
|
229
|
-
return readFile(this.#path, "utf-8");
|
|
230
|
-
}
|
|
231
|
-
async readJSON() {
|
|
232
|
-
return JSON.parse(await this.readText());
|
|
233
|
-
}
|
|
234
|
-
/** Creates intermediate directories if they do not exist.
|
|
235
|
-
*
|
|
236
|
-
* Returns the original `Path` (for chaining).
|
|
237
|
-
*/
|
|
238
|
-
async write(data, options) {
|
|
239
|
-
await this.parent.mkdir();
|
|
240
|
-
await writeFile(this.#path, data, options);
|
|
241
|
-
return this;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* If only `data` is provided, this is equivalent to:
|
|
245
|
-
*
|
|
246
|
-
* .write(JSON.stringify(data, null, " "));
|
|
247
|
-
*
|
|
248
|
-
* `replacer` and `space` can also be specified, making this equivalent to:
|
|
249
|
-
*
|
|
250
|
-
* .write(JSON.stringify(data, replacer, space));
|
|
251
|
-
*
|
|
252
|
-
* Returns the original `Path` (for chaining).
|
|
253
|
-
*/
|
|
254
|
-
async writeJSON(data, replacer = null, space = " ") {
|
|
255
|
-
await this.write(JSON.stringify(data, replacer, space));
|
|
256
|
-
return this;
|
|
257
|
-
}
|
|
258
|
-
// Normally we'd add a `@deprecated` alias named `.readdir`, but that would
|
|
259
|
-
// differ only by capitalization of a single non-leading character. This can
|
|
260
|
-
// be a bit confusing, especially when autocompleting. So for this function in
|
|
261
|
-
// particular we don't include an alias.
|
|
262
|
-
readDir = (options) => (
|
|
263
|
-
// biome-ignore lint/suspicious/noExplicitAny: Needed to wrangle the types.
|
|
264
|
-
readdir(this.#path, options)
|
|
265
|
-
);
|
|
266
|
-
static get homedir() {
|
|
267
|
-
return new _Path(homedir());
|
|
268
|
-
}
|
|
269
|
-
static xdg = {
|
|
270
|
-
cache: new _Path(xdgCache ?? _Path.homedir.join(".cache")),
|
|
271
|
-
config: new _Path(xdgConfig ?? _Path.homedir.join(".config")),
|
|
272
|
-
data: new _Path(xdgData ?? _Path.homedir.join(".local/share")),
|
|
273
|
-
state: new _Path(xdgState ?? _Path.homedir.join(".local/state"))
|
|
274
|
-
};
|
|
275
|
-
/** Chainable function to print the path. Prints the same as:
|
|
276
|
-
*
|
|
277
|
-
* if (args.length > 0) {
|
|
278
|
-
* console.log(...args);
|
|
279
|
-
* }
|
|
280
|
-
* console.log(this.path);
|
|
281
|
-
*
|
|
282
|
-
*/
|
|
283
|
-
// biome-ignore lint/suspicious/noExplicitAny: This is the correct type, based on `console.log(…)`.
|
|
284
|
-
debugPrint(...args) {
|
|
285
|
-
if (args.length > 0) {
|
|
286
|
-
console.log(...args);
|
|
287
|
-
}
|
|
288
|
-
console.log(this.#path);
|
|
289
|
-
return this;
|
|
290
|
-
}
|
|
291
|
-
};
|
|
2
|
+
Path,
|
|
3
|
+
mustNotHaveTrailingSlash,
|
|
4
|
+
stringifyIfPath
|
|
5
|
+
} from "./chunks/chunk-KSCIGSNU.js";
|
|
292
6
|
export {
|
|
293
|
-
Path
|
|
7
|
+
Path,
|
|
8
|
+
mustNotHaveTrailingSlash,
|
|
9
|
+
stringifyIfPath
|
|
294
10
|
};
|
|
295
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"sourcesContent": ["import type { Abortable } from \"node:events\";\nimport type { Dirent, ObjectEncodingOptions, OpenMode } from \"node:fs\";\nimport {\n cp,\n mkdir,\n mkdtemp,\n readdir,\n readFile,\n rename,\n rm,\n stat,\n writeFile,\n} from \"node:fs/promises\";\nimport { homedir, tmpdir } from \"node:os\";\nimport { basename, dirname, extname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport { xdgCache, xdgConfig, xdgData, xdgState } from \"xdg-basedir\";\n\n// Modifying the type of `readdir(\u2026)` from `node:fs/promises` to remove the\n// first parameter is difficult, if not impossible. So we give up and duplicate\n// the types manually. This ensures ergonomic types, such as an inferred return\n// type of `string[]` when `options` is not passed.\n\ndeclare function readDirType(\n options?:\n | (ObjectEncodingOptions & {\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n })\n | BufferEncoding\n | null,\n): Promise<string[]>;\n\ndeclare function readDirType(\n options:\n | {\n encoding: \"buffer\";\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n }\n | \"buffer\",\n): Promise<Buffer[]>;\n\ndeclare function readDirType(\n options?:\n | (ObjectEncodingOptions & {\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n })\n | BufferEncoding\n | null,\n): Promise<string[] | Buffer[]>;\n\ndeclare function readDirType(\n options: ObjectEncodingOptions & {\n withFileTypes: true;\n recursive?: boolean | undefined;\n },\n): Promise<Dirent[]>;\n\ndeclare function readDirType(options: {\n encoding: \"buffer\";\n withFileTypes: true;\n recursive?: boolean | undefined;\n}): Promise<Dirent<Buffer>[]>;\n\ndeclare function readFileType(\n options?:\n | ({\n encoding?: null | undefined;\n flag?: OpenMode | undefined;\n } & Abortable)\n | null,\n): Promise<Buffer>;\ndeclare function readFileType(\n options:\n | ({\n encoding: BufferEncoding;\n flag?: OpenMode | undefined;\n } & Abortable)\n | BufferEncoding,\n): Promise<string>;\ndeclare function readFileType(\n options?:\n | (ObjectEncodingOptions &\n Abortable & {\n flag?: OpenMode | undefined;\n })\n | BufferEncoding\n | null,\n): Promise<string | Buffer>;\n\nexport class Path {\n // @ts-expect-error ts(2564): False positive. https://github.com/microsoft/TypeScript/issues/32194\n #path: string;\n /**\n * If `path` is a string starting with `file:///`, it will be parsed as a file URL.\n */\n constructor(path: string | URL | Path) {\n this.#setNormalizedPath(Path.#pathlikeToString(path));\n }\n\n /**\n * Similar to `new URL(path, base)`, but accepting and returning `Path` objects.\n * Note that `base` must be one of:\n *\n * - a valid second argument to `new URL(\u2026)`.\n * - a `Path` representing an absolute path.\n *\n */\n static resolve(path: string | URL | Path, base: string | URL | Path): Path {\n const baseURL = (() => {\n if (!(base instanceof Path)) {\n return base;\n }\n if (!base.isAbsolutePath()) {\n throw new Error(\n \"The `base` arg to `Path.resolve(\u2026)` must be an absolute path.\",\n );\n }\n return pathToFileURL(base.#path);\n })();\n return new Path(new URL(Path.#pathlikeToString(path), baseURL));\n }\n\n static #pathlikeToString(path: string | URL | Path): string {\n if (path instanceof Path) {\n return path.#path;\n }\n if (path instanceof URL) {\n return fileURLToPath(path);\n }\n if (typeof path === \"string\") {\n // TODO: allow turning off this heuristic?\n if (path.startsWith(\"file:///\")) {\n return fileURLToPath(path);\n }\n return path;\n }\n throw new Error(\"Invalid path\");\n }\n\n #setNormalizedPath(path: string): void {\n this.#path = join(path);\n }\n\n isAbsolutePath(): boolean {\n return this.#path.startsWith(\"/\");\n }\n\n toFileURL(): URL {\n if (!this.isAbsolutePath()) {\n throw new Error(\n \"Tried to convert to file URL when the path is not absolute.\",\n );\n }\n return pathToFileURL(this.#path);\n }\n\n /**\n * The `Path` can have a trailing slash, indicating that it represents a\n * directory. (If there is no trailing slash, it can represent either a file\n * or a directory.)\n *\n * Some operations will refuse to treat a directory path as a file path. This\n * function identifies such paths.\n */\n hasTrailingSlash(): boolean {\n // TODO: handle Windows semantically\n return this.#path.endsWith(\"/\");\n }\n\n /**\n * Same as `.toString()`, but more concise.\n */\n get path() {\n return this.#path;\n }\n\n toString(): string {\n return this.#path;\n }\n\n /** Constructs a new path by appending the given path segments.\n * This follows `node` semantics for absolute paths: leading slashes in the given descendant segments are ignored.\n */\n join(...segments: (string | Path)[]): Path {\n const segmentStrings = segments.map((segment) =>\n segment instanceof Path ? segment.path : segment,\n );\n return new Path(join(this.#path, ...segmentStrings));\n }\n\n extendBasename(suffix: string): Path {\n const joinedSuffix = join(suffix);\n if (joinedSuffix !== basename(joinedSuffix)) {\n throw new Error(\"Invalid suffix to extend file name.\");\n }\n // TODO: join basename and dirname instead?\n return new Path(this.#path + joinedSuffix);\n }\n\n get parent(): Path {\n return new Path(dirname(this.#path));\n }\n\n // Normally I'd stick with `node`'s name, but I think `.dirname` is a\n // particularly poor name. So we support `.dirname` for discovery but mark it\n // as deprecated, even if it will never be removed.\n /** @deprecated Alias for `.parent`. */\n get dirname(): Path {\n return this.parent;\n }\n\n get basename(): Path {\n return new Path(basename(this.#path));\n }\n\n get extension(): string {\n this.#mustNotHaveTrailingSlash();\n return extname(this.#path);\n }\n\n // Normally I'd stick with `node`'s name, but I think `.extname` is a\n // particularly poor name. So we support `.extname` for discovery but mark it\n // as deprecated, even if it will never be removed.\n /** @deprecated Alias for `.extension`. */\n get extname(): string {\n return this.extension;\n }\n\n #mustNotHaveTrailingSlash(): void {\n if (this.hasTrailingSlash()) {\n throw new Error(\n \"Path ends with a slash, which cannot be treated as a file.\",\n );\n }\n }\n\n async exists(constraints?: {\n mustBe: \"file\" | \"directory\";\n }): Promise<boolean> {\n let stats: Awaited<ReturnType<typeof stat>>;\n try {\n stats = await stat(this.#path);\n // biome-ignore lint/suspicious/noExplicitAny: TypeScript limitation\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n return false;\n }\n throw e;\n }\n if (!constraints?.mustBe) {\n return true;\n }\n switch (constraints?.mustBe) {\n case \"file\": {\n this.#mustNotHaveTrailingSlash();\n if (stats.isFile()) {\n return true;\n }\n throw new Error(`Path exists but is not a file: ${this.#path}`);\n }\n case \"directory\": {\n if (stats.isDirectory()) {\n return true;\n }\n throw new Error(`Path exists but is not a directory: ${this.#path}`);\n }\n default: {\n throw new Error(\"Invalid path type constraint\");\n }\n }\n }\n\n async existsAsFile(): Promise<boolean> {\n return this.exists({ mustBe: \"file\" });\n }\n\n async existsAsDir(): Promise<boolean> {\n return this.exists({ mustBe: \"directory\" });\n }\n\n // I don't think `mkdir` is a great name, but it does match the\n // well-established canonical commandline name. So in this case we keep the\n // awkward abbreviation.\n /** Defaults to `recursive: true`. */\n async mkdir(options?: Parameters<typeof mkdir>[1]): Promise<Path> {\n const optionsObject = (() => {\n if (typeof options === \"string\" || typeof options === \"number\") {\n return { mode: options };\n }\n return options ?? {};\n })();\n await mkdir(this.#path, { recursive: true, ...optionsObject });\n return this;\n }\n\n // TODO: check idempotency semantics when the destination exists and is a folder.\n /** Returns the destination path. */\n async cp(\n destination: string | URL | Path,\n options?: Parameters<typeof cp>[2],\n ): Promise<Path> {\n await cp(this.#path, new Path(destination).#path, options);\n return new Path(destination);\n }\n\n // TODO: check idempotency semantics when the destination exists and is a folder.\n async rename(destination: string | URL | Path): Promise<void> {\n await rename(this.#path, new Path(destination).#path);\n }\n\n /** Create a temporary dir inside the global temp dir for the current user. */\n static async makeTempDir(prefix?: string): Promise<Path> {\n return new Path(\n await mkdtemp(new Path(tmpdir()).join(prefix ?? \"js-temp-\").toString()),\n );\n }\n\n async rm(options?: Parameters<typeof rm>[1]): Promise<void> {\n await rm(this.#path, options);\n }\n\n /**\n * Equivalent to:\n *\n * .rm({ recursive: true, force: true, ...(options ?? {}) })\n *\n */\n async rm_rf(options?: Parameters<typeof rm>[1]): Promise<void> {\n await this.rm({ recursive: true, force: true, ...(options ?? {}) });\n }\n\n read: typeof readFileType = (options) =>\n // biome-ignore lint/suspicious/noExplicitAny: Needed to wrangle the types.\n readFile(this.#path, options as any) as any;\n\n async readText(): Promise<string> {\n return readFile(this.#path, \"utf-8\");\n }\n\n async readJSON<T>(): Promise<T> {\n return JSON.parse(await this.readText());\n }\n\n /** Creates intermediate directories if they do not exist.\n *\n * Returns the original `Path` (for chaining).\n */\n async write(\n data: Parameters<typeof writeFile>[1],\n options?: Parameters<typeof writeFile>[2],\n ): Promise<Path> {\n await this.parent.mkdir();\n await writeFile(this.#path, data, options);\n return this;\n }\n\n /**\n * If only `data` is provided, this is equivalent to:\n *\n * .write(JSON.stringify(data, null, \" \"));\n *\n * `replacer` and `space` can also be specified, making this equivalent to:\n *\n * .write(JSON.stringify(data, replacer, space));\n *\n * Returns the original `Path` (for chaining).\n */\n async writeJSON<T>(\n data: T,\n replacer: Parameters<typeof JSON.stringify>[1] = null,\n space: Parameters<typeof JSON.stringify>[2] = \" \",\n ): Promise<Path> {\n await this.write(JSON.stringify(data, replacer, space));\n return this;\n }\n\n // Normally we'd add a `@deprecated` alias named `.readdir`, but that would\n // differ only by capitalization of a single non-leading character. This can\n // be a bit confusing, especially when autocompleting. So for this function in\n // particular we don't include an alias.\n readDir: typeof readDirType = (options) =>\n // biome-ignore lint/suspicious/noExplicitAny: Needed to wrangle the types.\n readdir(this.#path, options as any) as any;\n\n static get homedir(): Path {\n return new Path(homedir());\n }\n\n static xdg = {\n cache: new Path(xdgCache ?? Path.homedir.join(\".cache\")),\n config: new Path(xdgConfig ?? Path.homedir.join(\".config\")),\n data: new Path(xdgData ?? Path.homedir.join(\".local/share\")),\n state: new Path(xdgState ?? Path.homedir.join(\".local/state\")),\n };\n\n /** Chainable function to print the path. Prints the same as:\n *\n * if (args.length > 0) {\n * console.log(...args);\n * }\n * console.log(this.path);\n *\n */\n // biome-ignore lint/suspicious/noExplicitAny: This is the correct type, based on `console.log(\u2026)`.\n debugPrint(...args: any[]): Path {\n if (args.length > 0) {\n console.log(...args);\n }\n console.log(this.#path);\n return this;\n }\n}\n"],
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": [],
|
|
4
|
+
"sourcesContent": [],
|
|
5
|
+
"mappings": "",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { cpSync, type Dirent, mkdirSync, type ObjectEncodingOptions, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import "./static";
|
|
3
|
+
declare function readFileSyncType(options?: {
|
|
4
|
+
encoding?: null | undefined;
|
|
5
|
+
flag?: string | undefined;
|
|
6
|
+
} | null): NonSharedBuffer;
|
|
7
|
+
declare function readFileSyncType(options: {
|
|
8
|
+
encoding: BufferEncoding;
|
|
9
|
+
flag?: string | undefined;
|
|
10
|
+
} | BufferEncoding): string;
|
|
11
|
+
declare function readFileSyncType(options?: (ObjectEncodingOptions & {
|
|
12
|
+
flag?: string | undefined;
|
|
13
|
+
}) | BufferEncoding | null): string | NonSharedBuffer;
|
|
14
|
+
declare function readDirSyncType(options?: {
|
|
15
|
+
encoding: BufferEncoding | null;
|
|
16
|
+
withFileTypes?: false | undefined;
|
|
17
|
+
recursive?: boolean | undefined;
|
|
18
|
+
} | BufferEncoding | null): string[];
|
|
19
|
+
declare function readDirSyncType(options: {
|
|
20
|
+
encoding: "buffer";
|
|
21
|
+
withFileTypes?: false | undefined;
|
|
22
|
+
recursive?: boolean | undefined;
|
|
23
|
+
} | "buffer"): Buffer[];
|
|
24
|
+
declare function readDirSyncType(options?: (ObjectEncodingOptions & {
|
|
25
|
+
withFileTypes?: false | undefined;
|
|
26
|
+
recursive?: boolean | undefined;
|
|
27
|
+
}) | BufferEncoding | null): string[] | Buffer[];
|
|
28
|
+
declare function readDirSyncType(options: ObjectEncodingOptions & {
|
|
29
|
+
withFileTypes: true;
|
|
30
|
+
recursive?: boolean | undefined;
|
|
31
|
+
}): Dirent[];
|
|
32
|
+
declare function readDirSyncType(options: {
|
|
33
|
+
encoding: "buffer";
|
|
34
|
+
withFileTypes: true;
|
|
35
|
+
recursive?: boolean | undefined;
|
|
36
|
+
}): Dirent<Buffer>[];
|
|
37
|
+
declare module "../Path" {
|
|
38
|
+
interface Path {
|
|
39
|
+
existsSync(constraints?: {
|
|
40
|
+
mustBe: "file" | "directory";
|
|
41
|
+
}): boolean;
|
|
42
|
+
existsAsFileSync(): boolean;
|
|
43
|
+
existsAsDirSync(): boolean;
|
|
44
|
+
mkdirSync(options?: Parameters<typeof mkdirSync>[1]): Path;
|
|
45
|
+
cpSync(destination: string | URL | Path, options?: Parameters<typeof cpSync>[2]): Path;
|
|
46
|
+
renameSync(destination: string | URL | Path): void;
|
|
47
|
+
rmSync(options?: Parameters<typeof rmSync>[1]): void;
|
|
48
|
+
rm_rfSync(options?: Parameters<typeof rmSync>[1]): void;
|
|
49
|
+
readSync: typeof readFileSyncType;
|
|
50
|
+
readTextSync(): string;
|
|
51
|
+
readJSONSync<T>(): T;
|
|
52
|
+
writeSync(data: Parameters<typeof writeFileSync>[1], options?: Parameters<typeof writeFileSync>[2] | undefined): Path;
|
|
53
|
+
writeJSONSync<T>(data: T, replacer?: Parameters<typeof JSON.stringify>[1], space?: Parameters<typeof JSON.stringify>[2]): Path;
|
|
54
|
+
readDirSync: typeof readDirSyncType;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Path,
|
|
3
|
+
mustNotHaveTrailingSlash
|
|
4
|
+
} from "../chunks/chunk-KSCIGSNU.js";
|
|
5
|
+
|
|
6
|
+
// src/sync/index.ts
|
|
7
|
+
import {
|
|
8
|
+
cpSync,
|
|
9
|
+
mkdirSync,
|
|
10
|
+
readdirSync,
|
|
11
|
+
readFileSync,
|
|
12
|
+
renameSync,
|
|
13
|
+
rmSync,
|
|
14
|
+
statSync,
|
|
15
|
+
writeFileSync
|
|
16
|
+
} from "node:fs";
|
|
17
|
+
|
|
18
|
+
// src/sync/static.ts
|
|
19
|
+
import { mkdtempSync } from "node:fs";
|
|
20
|
+
import { tmpdir } from "node:os";
|
|
21
|
+
Path.makeTempDirSync = (prefix) => new Path(
|
|
22
|
+
mkdtempSync(new Path(tmpdir()).join(prefix ?? "js-temp-").toString())
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
// src/sync/index.ts
|
|
26
|
+
Path.prototype.existsSync = function(constraints) {
|
|
27
|
+
let stats;
|
|
28
|
+
try {
|
|
29
|
+
stats = statSync(this.path);
|
|
30
|
+
} catch (e) {
|
|
31
|
+
if (e.code === "ENOENT") {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
throw e;
|
|
35
|
+
}
|
|
36
|
+
if (!constraints?.mustBe) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
switch (constraints?.mustBe) {
|
|
40
|
+
case "file": {
|
|
41
|
+
mustNotHaveTrailingSlash(this);
|
|
42
|
+
if (stats.isFile()) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
throw new Error(`Path exists but is not a file: ${this.path}`);
|
|
46
|
+
}
|
|
47
|
+
case "directory": {
|
|
48
|
+
if (stats.isDirectory()) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
throw new Error(`Path exists but is not a directory: ${this.path}`);
|
|
52
|
+
}
|
|
53
|
+
default: {
|
|
54
|
+
throw new Error("Invalid path type constraint");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
Path.prototype.existsAsFileSync = function() {
|
|
59
|
+
return this.existsSync({ mustBe: "file" });
|
|
60
|
+
};
|
|
61
|
+
Path.prototype.existsAsDirSync = function() {
|
|
62
|
+
return this.existsSync({ mustBe: "directory" });
|
|
63
|
+
};
|
|
64
|
+
Path.prototype.mkdirSync = function(options) {
|
|
65
|
+
const optionsObject = (() => {
|
|
66
|
+
if (typeof options === "string" || typeof options === "number") {
|
|
67
|
+
return { mode: options };
|
|
68
|
+
}
|
|
69
|
+
return options ?? {};
|
|
70
|
+
})();
|
|
71
|
+
mkdirSync(this.path, { recursive: true, ...optionsObject });
|
|
72
|
+
return this;
|
|
73
|
+
};
|
|
74
|
+
Path.prototype.cpSync = function(destination, options) {
|
|
75
|
+
cpSync(this.path, new Path(destination).path, options);
|
|
76
|
+
return new Path(destination);
|
|
77
|
+
};
|
|
78
|
+
Path.prototype.renameSync = function(destination) {
|
|
79
|
+
renameSync(this.path, new Path(destination).path);
|
|
80
|
+
};
|
|
81
|
+
Path.prototype.rmSync = function(options) {
|
|
82
|
+
rmSync(this.path, options);
|
|
83
|
+
};
|
|
84
|
+
Path.prototype.rm_rfSync = function(options) {
|
|
85
|
+
this.rmSync({ recursive: true, force: true, ...options ?? {} });
|
|
86
|
+
};
|
|
87
|
+
Path.prototype.readSync = function() {
|
|
88
|
+
return readFileSync(this.path);
|
|
89
|
+
};
|
|
90
|
+
Path.prototype.readTextSync = function() {
|
|
91
|
+
return readFileSync(this.path, "utf-8");
|
|
92
|
+
};
|
|
93
|
+
Path.prototype.readJSONSync = function() {
|
|
94
|
+
return JSON.parse(this.readTextSync());
|
|
95
|
+
};
|
|
96
|
+
Path.prototype.writeSync = function(data, options) {
|
|
97
|
+
this.parent.mkdirSync();
|
|
98
|
+
writeFileSync(this.path, data, options);
|
|
99
|
+
return this;
|
|
100
|
+
};
|
|
101
|
+
Path.prototype.writeJSONSync = function(data, replacer = null, space = " ") {
|
|
102
|
+
this.parent.mkdirSync();
|
|
103
|
+
this.writeSync(JSON.stringify(data, replacer, space));
|
|
104
|
+
return this;
|
|
105
|
+
};
|
|
106
|
+
Path.prototype.readDirSync = function(options) {
|
|
107
|
+
return readdirSync(this.path, options);
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/sync/index.ts", "../../../../src/sync/static.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n cpSync,\n type Dirent,\n mkdirSync,\n type ObjectEncodingOptions,\n readdirSync,\n readFileSync,\n renameSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\";\nimport { mustNotHaveTrailingSlash, Path } from \"../Path\";\nimport \"./static\";\n\n// Note that (non-static) functions in this file are defined using `function(\u2026)\n// { \u2026 }` rather than arrow functions, specifically because we want `this` to\n// operate on the `Path` instance.\n\ndeclare function readFileSyncType(\n options?: {\n encoding?: null | undefined;\n flag?: string | undefined;\n } | null,\n): NonSharedBuffer;\ndeclare function readFileSyncType(\n options:\n | {\n encoding: BufferEncoding;\n flag?: string | undefined;\n }\n | BufferEncoding,\n): string;\ndeclare function readFileSyncType(\n options?:\n | (ObjectEncodingOptions & {\n flag?: string | undefined;\n })\n | BufferEncoding\n | null,\n): string | NonSharedBuffer;\n\ndeclare function readDirSyncType(\n options?:\n | {\n encoding: BufferEncoding | null;\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n }\n | BufferEncoding\n | null,\n): string[];\ndeclare function readDirSyncType(\n options:\n | {\n encoding: \"buffer\";\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n }\n | \"buffer\",\n): Buffer[];\ndeclare function readDirSyncType(\n options?:\n | (ObjectEncodingOptions & {\n withFileTypes?: false | undefined;\n recursive?: boolean | undefined;\n })\n | BufferEncoding\n | null,\n): string[] | Buffer[];\ndeclare function readDirSyncType(\n options: ObjectEncodingOptions & {\n withFileTypes: true;\n recursive?: boolean | undefined;\n },\n): Dirent[];\ndeclare function readDirSyncType(options: {\n encoding: \"buffer\";\n withFileTypes: true;\n recursive?: boolean | undefined;\n}): Dirent<Buffer>[];\n\ndeclare module \"../Path\" {\n interface Path {\n existsSync(constraints?: { mustBe: \"file\" | \"directory\" }): boolean;\n existsAsFileSync(): boolean;\n existsAsDirSync(): boolean;\n\n mkdirSync(options?: Parameters<typeof mkdirSync>[1]): Path;\n cpSync(\n destination: string | URL | Path,\n options?: Parameters<typeof cpSync>[2],\n ): Path;\n renameSync(destination: string | URL | Path): void;\n\n rmSync(options?: Parameters<typeof rmSync>[1]): void;\n rm_rfSync(options?: Parameters<typeof rmSync>[1]): void;\n\n readSync: typeof readFileSyncType;\n readTextSync(): string;\n readJSONSync<T>(): T;\n\n writeSync(\n data: Parameters<typeof writeFileSync>[1],\n options?: Parameters<typeof writeFileSync>[2] | undefined,\n ): Path;\n writeJSONSync<T>(\n data: T,\n replacer?: Parameters<typeof JSON.stringify>[1],\n space?: Parameters<typeof JSON.stringify>[2],\n ): Path;\n\n readDirSync: typeof readDirSyncType;\n }\n}\n\n// TODO: find a neat way to dedup with the async version?\nPath.prototype.existsSync = function (constraints?: {\n mustBe: \"file\" | \"directory\";\n}): boolean {\n let stats: ReturnType<typeof statSync>;\n try {\n stats = statSync(this.path);\n // biome-ignore lint/suspicious/noExplicitAny: TypeScript limitation\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n return false;\n }\n throw e;\n }\n if (!constraints?.mustBe) {\n return true;\n }\n switch (constraints?.mustBe) {\n case \"file\": {\n mustNotHaveTrailingSlash(this);\n if (stats.isFile()) {\n return true;\n }\n throw new Error(`Path exists but is not a file: ${this.path}`);\n }\n case \"directory\": {\n if (stats.isDirectory()) {\n return true;\n }\n throw new Error(`Path exists but is not a directory: ${this.path}`);\n }\n default: {\n throw new Error(\"Invalid path type constraint\");\n }\n }\n};\n\nPath.prototype.existsAsFileSync = function (): boolean {\n return this.existsSync({ mustBe: \"file\" });\n};\n\nPath.prototype.existsAsDirSync = function (): boolean {\n return this.existsSync({ mustBe: \"directory\" });\n};\n\nPath.prototype.mkdirSync = function (\n options?: Parameters<typeof mkdirSync>[1],\n): Path {\n const optionsObject = (() => {\n if (typeof options === \"string\" || typeof options === \"number\") {\n return { mode: options };\n }\n return options ?? {};\n })();\n mkdirSync(this.path, { recursive: true, ...optionsObject });\n return this;\n};\n\nPath.prototype.cpSync = function (\n destination: string | URL | Path,\n options?: Parameters<typeof cpSync>[2],\n): Path {\n cpSync(this.path, new Path(destination).path, options);\n return new Path(destination);\n};\n\nPath.prototype.renameSync = function (destination: string | URL | Path): void {\n renameSync(this.path, new Path(destination).path);\n};\n\nPath.prototype.rmSync = function (\n options?: Parameters<typeof rmSync>[1],\n): void {\n rmSync(this.path, options);\n};\n\nPath.prototype.rm_rfSync = function (\n options?: Parameters<typeof rmSync>[1],\n): void {\n this.rmSync({ recursive: true, force: true, ...(options ?? {}) });\n};\n\nPath.prototype.readSync = function () {\n /** @ts-expect-error ts(2683) */\n return readFileSync(this.path);\n} as typeof readFileSyncType;\n\nPath.prototype.readTextSync = function (): string {\n return readFileSync(this.path, \"utf-8\");\n};\n\nPath.prototype.readJSONSync = function <T>(): T {\n return JSON.parse(this.readTextSync());\n};\n\nPath.prototype.writeSync = function (\n data: Parameters<typeof writeFileSync>[1],\n options?: Parameters<typeof writeFileSync>[2],\n): Path {\n this.parent.mkdirSync();\n writeFileSync(this.path, data, options);\n return this;\n};\n\nPath.prototype.writeJSONSync = function <T>(\n data: T,\n replacer: Parameters<typeof JSON.stringify>[1] = null,\n space: Parameters<typeof JSON.stringify>[2] = \" \",\n): Path {\n this.parent.mkdirSync();\n this.writeSync(JSON.stringify(data, replacer, space));\n return this;\n};\n\n/** @ts-expect-error ts(2322): Wrangle types */\nPath.prototype.readDirSync = function (options) {\n // biome-ignore lint/suspicious/noExplicitAny: Needed to wrangle the types.\n return readdirSync(this.path, options as any);\n};\n", "import { mkdtempSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { Path } from \"../Path\";\n\ndeclare module \"../Path\" {\n namespace Path {\n export function makeTempDirSync(prefix?: string): Path;\n }\n}\n\nPath.makeTempDirSync = (prefix?: string): Path =>\n new Path(\n mkdtempSync(new Path(tmpdir()).join(prefix ?? \"js-temp-\").toString()),\n );\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "path-class",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"author": "Lucas Garron <code@garron.net>",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/lib/path-class/index.js",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/lib/path-class/index.d.ts",
|
|
11
11
|
"import": "./dist/lib/path-class/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./sync": {
|
|
14
|
+
"types": "./dist/lib/path-class/sync/index.d.ts",
|
|
15
|
+
"import": "./dist/lib/path-class/sync/index.js"
|
|
12
16
|
}
|
|
13
17
|
},
|
|
14
18
|
"devDependencies": {
|