pwd-fs 2.1.11 → 2.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/lib/src/index.d.ts +9 -6
- package/lib/src/index.js +1 -0
- package/lib/src/index.js.map +1 -1
- package/package.json +9 -10
- package/readme.md +29 -18
- package/src/index.ts +13 -7
- package/tsconfig.json +1 -2
package/lib/src/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
declare type
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare type Mode = 'e' | 'r' | 'w' | 'x';
|
|
4
|
+
export declare type Flag = Mode | 'a';
|
|
5
|
+
export interface Constants {
|
|
6
|
+
e: number;
|
|
7
|
+
r: number;
|
|
8
|
+
w: number;
|
|
9
|
+
x: number;
|
|
6
10
|
}
|
|
7
11
|
export default class PoweredFileSystem {
|
|
8
12
|
readonly pwd: string;
|
|
@@ -11,12 +15,12 @@ export default class PoweredFileSystem {
|
|
|
11
15
|
test(src: string, options: {
|
|
12
16
|
sync: true;
|
|
13
17
|
resolve?: boolean;
|
|
14
|
-
flag?:
|
|
18
|
+
flag?: Mode;
|
|
15
19
|
}): boolean;
|
|
16
20
|
test(src: string, options?: {
|
|
17
21
|
sync?: false;
|
|
18
22
|
resolve?: boolean;
|
|
19
|
-
flag?:
|
|
23
|
+
flag?: Mode;
|
|
20
24
|
}): Promise<boolean>;
|
|
21
25
|
stat(src: string, options: {
|
|
22
26
|
sync: true;
|
|
@@ -179,4 +183,3 @@ export default class PoweredFileSystem {
|
|
|
179
183
|
private resolve;
|
|
180
184
|
static bitmask(mode: number): number;
|
|
181
185
|
}
|
|
182
|
-
export {};
|
package/lib/src/index.js
CHANGED
|
@@ -200,6 +200,7 @@ class PoweredFileSystem {
|
|
|
200
200
|
});
|
|
201
201
|
}
|
|
202
202
|
append(src, data, { sync = false, resolve = true, encoding = 'utf8', umask = 0o000, flag = 'a' } = {}) {
|
|
203
|
+
console.log(`'append' with be removed in the next major version. Use 'write' with { flag: 'a' } option`);
|
|
203
204
|
if (resolve) {
|
|
204
205
|
src = this.resolve(src);
|
|
205
206
|
}
|
package/lib/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,8DAAmC;AACnC,wEAA4C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,8DAAmC;AACnC,wEAA4C;AAY5C,MAAqB,iBAAiB;IAUpC,YAAY,GAAY;QATf,QAAG,GAAW,OAAO,CAAC,GAAG,EAAE,CAAC;QAE5B,cAAS,GAAc;YAC9B,CAAC,EAAE,YAAE,CAAC,SAAS,CAAC,IAAI;YACpB,CAAC,EAAE,YAAE,CAAC,SAAS,CAAC,IAAI;YACpB,CAAC,EAAE,YAAE,CAAC,SAAS,CAAC,IAAI;YACpB,CAAC,EAAE,YAAE,CAAC,SAAS,CAAC,IAAI;SACrB,CAAC;QAGA,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;SAC9B;IACH,CAAC;IAcD,IAAI,CAAC,GAAW,EAAE,EAAE,IAAI,GAAG,KAAK,EAAE,OAAO,GAAG,IAAI,EAAE,IAAI,GAAG,GAAG,KAIxD,EAAE;QACJ,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAElC,IAAI,OAAO,EAAE;YACX,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SACnC;QAED,IAAI,IAAI,EAAE;YACR,OAAO,YAAE,CAAC,UAAU,C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QAED,IAAI,IAAI,GAAG,EAAE,EAAE;YACb,KAAK,IAAI,KAAK,CAAC;SAChB;QAED,IAAI,IAAI,GAAG,EAAE,EAAE;YACb,KAAK,IAAI,KAAK,CAAC;SAChB;QAED,IAAI,IAAI,GAAG,EAAE,EAAE;YACb,KAAK,IAAI,KAAK,CAAC;SAChB;QAED,IAAI,IAAI,GAAG,CAAC,EAAE;YACZ,KAAK,IAAI,KAAK,CAAC;SAChB;QAED,IAAI,IAAI,GAAG,CAAC,EAAE;YACZ,KAAK,IAAI,KAAK,CAAC;SAChB;QAED,IAAI,IAAI,GAAG,CAAC,EAAE;YACZ,KAAK,IAAI,KAAK,CAAC;SAChB;QAED,IAAI,IAAI,GAAG,CAAC,EAAE;YACZ,KAAK,IAAI,KAAK,CAAC;SAChB;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAlmBD,oCAkmBC;AAED,MAAM,CAAC,OAAO,GAAG,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pwd-fs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Extend the file system the capabilities of declaring the present working directory and recursive execution",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"umask",
|
|
@@ -37,15 +37,14 @@
|
|
|
37
37
|
"test": "mocha ./lib/test"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@tsconfig/
|
|
40
|
+
"@tsconfig/node12": "^1.0.11",
|
|
41
41
|
"@types/chance": "^1.1.1",
|
|
42
|
-
"@types/mocha": "^
|
|
42
|
+
"@types/mocha": "^10.0.0",
|
|
43
43
|
"@types/mock-fs": "^4.13.0",
|
|
44
|
-
"@types/node": "^
|
|
45
|
-
"chance": "^1.1.
|
|
46
|
-
"mocha": "^
|
|
47
|
-
"mock-fs": "^
|
|
48
|
-
"typescript": "^4.
|
|
49
|
-
}
|
|
50
|
-
"dependencies": {}
|
|
44
|
+
"@types/node": "^18.11.9",
|
|
45
|
+
"chance": "^1.1.9",
|
|
46
|
+
"mocha": "^10.1.0",
|
|
47
|
+
"mock-fs": "^5.2.0",
|
|
48
|
+
"typescript": "^4.8.4"
|
|
49
|
+
}
|
|
51
50
|
}
|
package/readme.md
CHANGED
|
@@ -62,7 +62,7 @@ This class implemented by following the [ECMAScript® 2018 Language Specificatio
|
|
|
62
62
|
|
|
63
63
|
String form paths are interpreted as UTF-8 character sequences identifying the absolute or relative filename.
|
|
64
64
|
|
|
65
|
-
```
|
|
65
|
+
```ts
|
|
66
66
|
import PoweredFileSystem from 'pwd-fs';
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -74,7 +74,7 @@ const pfs = new PoweredFileSystem();
|
|
|
74
74
|
|
|
75
75
|
Relative paths will be resolved relative to the current working directory as specified by `process.cwd()`:
|
|
76
76
|
|
|
77
|
-
```
|
|
77
|
+
```ts
|
|
78
78
|
import PoweredFileSystem from 'pwd-fs';
|
|
79
79
|
|
|
80
80
|
/**
|
|
@@ -86,7 +86,7 @@ const pfs = new PoweredFileSystem('./foo/bar');
|
|
|
86
86
|
|
|
87
87
|
Absolute paths:
|
|
88
88
|
|
|
89
|
-
```
|
|
89
|
+
```ts
|
|
90
90
|
import PoweredFileSystem from 'pwd-fs';
|
|
91
91
|
|
|
92
92
|
/**
|
|
@@ -107,7 +107,7 @@ const pfs = new PoweredFileSystem(__dirname);
|
|
|
107
107
|
|
|
108
108
|
Tests a user's permissions for the file or directory specified by path.
|
|
109
109
|
|
|
110
|
-
```
|
|
110
|
+
```ts
|
|
111
111
|
const access = await pfs.test('./path');
|
|
112
112
|
console.log(test); // true
|
|
113
113
|
```
|
|
@@ -143,7 +143,7 @@ These functions return information about a resource in the file system.
|
|
|
143
143
|
|
|
144
144
|
Asynchronously changes the permissions of a file.
|
|
145
145
|
|
|
146
|
-
```
|
|
146
|
+
```ts
|
|
147
147
|
await pfs.chmod('./path', 0o750);
|
|
148
148
|
const { mode } = await pfs.stat('./path');
|
|
149
149
|
|
|
@@ -178,11 +178,11 @@ See manuals [chown(2)](http://man7.org/linux/man-pages/man2/chown.2.html).
|
|
|
178
178
|
|
|
179
179
|
Asynchronously creates a new symbolic link (also known as a soft link) may point to an existing file or to a nonexistent one.
|
|
180
180
|
|
|
181
|
-
```
|
|
181
|
+
```ts
|
|
182
182
|
await pfs.symlink('./path', './link');
|
|
183
|
-
const
|
|
183
|
+
const stats = await pfs.stat('./link');
|
|
184
184
|
|
|
185
|
-
console.log(
|
|
185
|
+
console.log(stats.isSymbolicLink()); // true
|
|
186
186
|
```
|
|
187
187
|
|
|
188
188
|
See manuals [symlink(2)](http://man7.org/linux/man-pages/man2/symlink.2.html).
|
|
@@ -199,7 +199,7 @@ See manuals [symlink(2)](http://man7.org/linux/man-pages/man2/symlink.2.html).
|
|
|
199
199
|
|
|
200
200
|
Asynchronously recursively copy a file or directory.
|
|
201
201
|
|
|
202
|
-
```
|
|
202
|
+
```ts
|
|
203
203
|
await pfs.copy('./path/file.txt', './dist');
|
|
204
204
|
const { mode } = await pfs.stat('./dist/path/file.txt');
|
|
205
205
|
|
|
@@ -217,7 +217,7 @@ console.log(PoweredFileSystem.bitmask(mode) === 0o666); // true
|
|
|
217
217
|
|
|
218
218
|
Rename file or directory. See manuals [rename(2)](http://man7.org/linux/man-pages/man2/rename.2.html).
|
|
219
219
|
|
|
220
|
-
```
|
|
220
|
+
```ts
|
|
221
221
|
await pfs.rename('./path/old_name.txt', './path/new_name.txt');
|
|
222
222
|
```
|
|
223
223
|
|
|
@@ -236,14 +236,14 @@ Asynchronously recursively remove a file or directory. Will be `resolve` if the
|
|
|
236
236
|
- `src` <[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)> Absolute or relative path to the resource in the file system. Relative paths will be resolved relative to the present working directory as specified by `pfs.pwd`.
|
|
237
237
|
- `options` <[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>
|
|
238
238
|
- `resolve` <[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)> Declaration whether relative paths will be resolved. **Default:** `true`.
|
|
239
|
-
- `encoding` <[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)> Is the expected [string encoding](#string-encoding). **Default:** `'utf8'`.
|
|
239
|
+
- `encoding` <[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)> | <[null](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null)> Is the expected [string encoding](#string-encoding). **Default:** `'utf8'`.
|
|
240
240
|
- `flag` <[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)> See support of [file system flags](#file-system-flags). **Default:** `'r'`.
|
|
241
241
|
- `sync` <[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)> Synchronous execution. **Default:** `false`.
|
|
242
|
-
- returns: <[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)> Following successful read, the `Promise` is resolved with an value with a `string`.
|
|
242
|
+
- returns: <[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)> Following successful read, the `Promise` is resolved with an value with a `string`. If no encoding is specified <[null](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null)>, the data is returned as a <[Buffer](https://nodejs.org/api/buffer.html)> object.
|
|
243
243
|
|
|
244
244
|
Asynchronously reads the entire contents of a file.
|
|
245
245
|
|
|
246
|
-
```
|
|
246
|
+
```ts
|
|
247
247
|
const content = await pfs.read('./file.txt');
|
|
248
248
|
console.log(content); // 'Lorem Ipsum...'
|
|
249
249
|
```
|
|
@@ -261,8 +261,9 @@ console.log(content); // 'Lorem Ipsum...'
|
|
|
261
261
|
- returns: <[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)> Following successful write, the `Promise` is resolved with an value with a `undefined`.
|
|
262
262
|
|
|
263
263
|
Asynchronously writes `data` to a file, replacing the file if it already exists. if the file does not exist, it will create a new one.
|
|
264
|
+
The encoding option is ignored if data is a buffer.
|
|
264
265
|
|
|
265
|
-
```
|
|
266
|
+
```ts
|
|
266
267
|
await pfs.write('./file.txt', '... some text');
|
|
267
268
|
```
|
|
268
269
|
|
|
@@ -282,18 +283,28 @@ await pfs.write('./file.txt', '... some text');
|
|
|
282
283
|
|
|
283
284
|
Asynchronously append data to a file, creating the file if it does not yet exist.
|
|
284
285
|
|
|
286
|
+
> NOTE Method is deprecated. To be removed in the next major version
|
|
287
|
+
|
|
288
|
+
**Use 'write' with { flag: 'a' } option**
|
|
289
|
+
|
|
290
|
+
```ts
|
|
291
|
+
await pfs.write('./file', 'some content', {
|
|
292
|
+
flag: 'a'
|
|
293
|
+
});
|
|
294
|
+
```
|
|
295
|
+
|
|
285
296
|
#### pfs.readdir(dir[, options]
|
|
286
297
|
|
|
287
298
|
- `dir` <[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)> Absolute or relative path to the directory you want to read.
|
|
288
299
|
- `options` <[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)>
|
|
289
300
|
- `resolve` <[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)> Declaration whether relative paths will be resolved. **Default:** `true`.
|
|
290
|
-
- `encoding` <[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)> Is the expected [string encoding](#string-encoding). **Default:** `'utf8'`.
|
|
301
|
+
- `encoding` <[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)> | <[null](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null)> Is the expected [string encoding](#string-encoding). **Default:** `'utf8'`.
|
|
291
302
|
- `sync` <[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)> Synchronous execution. **Default:** `false`.
|
|
292
|
-
- returns: <[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)> Following successful write, the `Promise` is resolved with an value with a `Array` of the names of the files in the directory excluding `'.'` and `'..'`.
|
|
303
|
+
- returns: <[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)> Following successful write, the `Promise` is resolved with an value with a `Array` of the names of the files in the directory excluding `'.'` and `'..'`. If no encoding is specified <[null](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null)>, the data is returned as a <[Buffer](https://nodejs.org/api/buffer.html)> object. Otherwise, the data will be a string.
|
|
293
304
|
|
|
294
305
|
Asynchronous reads the contents of a directory. The Gets an <[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)> of the names of the files in the directory excluding `'.'` and `'..'`. Returns an empty `Array` if the directory is empty. See manuals [readdir(3)](http://man7.org/linux/man-pages/man3/readdir.3.html).
|
|
295
306
|
|
|
296
|
-
```
|
|
307
|
+
```ts
|
|
297
308
|
const list = await pfs.readdir('./files');
|
|
298
309
|
console.log(list); // ["icons", "logo.svg"]
|
|
299
310
|
```
|
|
@@ -310,7 +321,7 @@ console.log(list); // ["icons", "logo.svg"]
|
|
|
310
321
|
|
|
311
322
|
Recursive directory creation. Will be `resolve` if the directory already exists.
|
|
312
323
|
|
|
313
|
-
```
|
|
324
|
+
```ts
|
|
314
325
|
await pfs.mkdir('./static/images');
|
|
315
326
|
```
|
|
316
327
|
|
package/src/index.ts
CHANGED
|
@@ -3,10 +3,14 @@ import path from 'path';
|
|
|
3
3
|
import recurse from './recurse-io';
|
|
4
4
|
import recurseSync from './recurse-io-sync';
|
|
5
5
|
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export type Mode = 'e' | 'r' | 'w' | 'x';
|
|
7
|
+
export type Flag = Mode | 'a';
|
|
8
|
+
|
|
9
|
+
export interface Constants {
|
|
10
|
+
e: number,
|
|
11
|
+
r: number,
|
|
12
|
+
w: number,
|
|
13
|
+
x: number
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
export default class PoweredFileSystem {
|
|
@@ -28,19 +32,19 @@ export default class PoweredFileSystem {
|
|
|
28
32
|
test(src: string, options: {
|
|
29
33
|
sync: true,
|
|
30
34
|
resolve?: boolean,
|
|
31
|
-
flag?:
|
|
35
|
+
flag?: Mode
|
|
32
36
|
}): boolean;
|
|
33
37
|
|
|
34
38
|
test(src: string, options?: {
|
|
35
39
|
sync?: false,
|
|
36
40
|
resolve?: boolean,
|
|
37
|
-
flag?:
|
|
41
|
+
flag?: Mode
|
|
38
42
|
}): Promise<boolean>;
|
|
39
43
|
|
|
40
44
|
test(src: string, { sync = false, resolve = true, flag = 'e' }: {
|
|
41
45
|
sync?: boolean,
|
|
42
46
|
resolve?: boolean,
|
|
43
|
-
flag?:
|
|
47
|
+
flag?: Mode
|
|
44
48
|
} = {}) {
|
|
45
49
|
const mode = this.constants[flag];
|
|
46
50
|
|
|
@@ -468,6 +472,8 @@ export default class PoweredFileSystem {
|
|
|
468
472
|
umask?: number,
|
|
469
473
|
flag?: Flag
|
|
470
474
|
} = {}) {
|
|
475
|
+
console.log(`'append' with be removed in the next major version. Use 'write' with { flag: 'a' } option`);
|
|
476
|
+
|
|
471
477
|
if (resolve) {
|
|
472
478
|
src = this.resolve(src);
|
|
473
479
|
}
|