pwd-fs 3.2.2 → 3.2.3
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/package.json +1 -1
- package/readme.md +35 -23
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -37,10 +37,10 @@ npm install pwd-fs
|
|
|
37
37
|
* [pfs.remove(src[, options])](#pfsremovesrc-options)
|
|
38
38
|
* [pfs.read(src[, options])](#pfsreadsrc-options)
|
|
39
39
|
* [pfs.write(src, data[, options])](#pfswritesrc-data-options)
|
|
40
|
-
* [pfs.append(src, data[, options])](#pfsappendsrc-data-options-deprecated) `deprecated`
|
|
41
40
|
* [pfs.readdir(dir[, options])](#pfsreaddirdir-options)
|
|
42
41
|
* [pfs.mkdir(dir[, options])](#pfsmkdirdir-options)
|
|
43
42
|
* [pfs.pwd](#pfspwd)
|
|
43
|
+
* [static: bitmask(mode)](#static-bitmaskmode)
|
|
44
44
|
|
|
45
45
|
The scope `URI` of the class methods are divided into groups.
|
|
46
46
|
|
|
@@ -65,9 +65,7 @@ String form paths are interpreted as UTF-8 character sequences identifying the a
|
|
|
65
65
|
```ts
|
|
66
66
|
import { pfs } from 'pwd-fs';
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
* pfs.pwd === process.cwd()
|
|
70
|
-
*/
|
|
68
|
+
// pfs.pwd === process.cwd()
|
|
71
69
|
```
|
|
72
70
|
|
|
73
71
|
Relative paths will be resolved relative to the current working directory as specified by `process.cwd()`:
|
|
@@ -75,9 +73,7 @@ Relative paths will be resolved relative to the current working directory as spe
|
|
|
75
73
|
```ts
|
|
76
74
|
import { PoweredFileSystem } from 'pwd-fs';
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
* pfs.pwd === `${process.cwd()}/foo/bar`
|
|
80
|
-
*/
|
|
76
|
+
// pfs.pwd === `${process.cwd()}/foo/bar`
|
|
81
77
|
|
|
82
78
|
const pfs = new PoweredFileSystem('./foo/bar');
|
|
83
79
|
```
|
|
@@ -87,9 +83,7 @@ Absolute paths:
|
|
|
87
83
|
```ts
|
|
88
84
|
import { PoweredFileSystem } from 'pwd-fs';
|
|
89
85
|
|
|
90
|
-
|
|
91
|
-
* pfs.pwd === __dirname
|
|
92
|
-
*/
|
|
86
|
+
// pfs.pwd === __dirname
|
|
93
87
|
|
|
94
88
|
const pfs = new PoweredFileSystem(__dirname);
|
|
95
89
|
```
|
|
@@ -194,12 +188,9 @@ See manuals [symlink(2)](http://man7.org/linux/man-pages/man2/symlink.2.html).
|
|
|
194
188
|
Asynchronously recursively copy a file or directory.
|
|
195
189
|
|
|
196
190
|
```ts
|
|
197
|
-
import {
|
|
191
|
+
import { pfs } from 'pwd-fs';
|
|
198
192
|
|
|
199
193
|
await pfs.copy('./path/file.txt', './dist');
|
|
200
|
-
const { mode } = await pfs.stat('./dist/path/file.txt');
|
|
201
|
-
|
|
202
|
-
console.log(bitmask(mode) === 0o666); // true
|
|
203
194
|
```
|
|
204
195
|
|
|
205
196
|
#### pfs.rename(src, use[, options])
|
|
@@ -321,19 +312,40 @@ await pfs.mkdir('./static/images');
|
|
|
321
312
|
|
|
322
313
|
The full path from the root directory to the present working directory: in the context of which relative paths will be resolved.
|
|
323
314
|
|
|
315
|
+
#### static: bitmask(mode)
|
|
316
|
+
|
|
317
|
+
Masking is the act of applying a mask to a value. Bitwise ANDing in order to extract a subset of the bits in the value.
|
|
318
|
+
|
|
319
|
+
```ts
|
|
320
|
+
import { bitmask } from 'pwd-fs';
|
|
321
|
+
|
|
322
|
+
// Access: (0644/-rw-r--r--)
|
|
323
|
+
const { mode } = await pfs.stat('./things.txt');
|
|
324
|
+
const access = bitmask(mode);
|
|
325
|
+
|
|
326
|
+
console.log(access === 0o644); // true
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Applying the mask to the value means that we want to clear the first (higher) 4 bits, and keep the last (lower) 4 bits. Thus we have extracted the lower 4 bits. The result is:
|
|
330
|
+
|
|
331
|
+
```
|
|
332
|
+
mode: 33188
|
|
333
|
+
mask: 0o644 (rw-rw-r--)
|
|
334
|
+
```
|
|
335
|
+
|
|
324
336
|
#### Mode creation mask
|
|
325
337
|
|
|
326
338
|
The following table shows some examples of how to set the extension `mode` or `umask` for files and directories.
|
|
327
339
|
|
|
328
|
-
Umask | Mode files
|
|
329
|
-
|
|
330
|
-
0o000 | 0o666 (rw-rw-rw-) | 0o777 (rwxrwxrwx)
|
|
331
|
-
0o002 | 0o664 (rw-rw-r--) | 0o775 (rwxrwxr-x)
|
|
332
|
-
0o007 | 0o660 (rw-rw----) | 0o770 (rwxrwx---)
|
|
333
|
-
0o022 | 0o644 (rw-r--r--) | 0o755 (rwxr-xr-x)
|
|
334
|
-
0o027 | 0o640 (rw-r-----) | 0o750 (rwxr-x---)
|
|
335
|
-
0o077 | 0o600 (rw-------) | 0o700 (rwx------)
|
|
336
|
-
0o277 | 0o400 (r--------) | 0o500 (r-x------)
|
|
340
|
+
| Umask | Mode files | Mode directories |
|
|
341
|
+
|-------|-------------------|-------------------|
|
|
342
|
+
| 0o000 | 0o666 (rw-rw-rw-) | 0o777 (rwxrwxrwx) |
|
|
343
|
+
| 0o002 | 0o664 (rw-rw-r--) | 0o775 (rwxrwxr-x) |
|
|
344
|
+
| 0o007 | 0o660 (rw-rw----) | 0o770 (rwxrwx---) |
|
|
345
|
+
| 0o022 | 0o644 (rw-r--r--) | 0o755 (rwxr-xr-x) |
|
|
346
|
+
| 0o027 | 0o640 (rw-r-----) | 0o750 (rwxr-x---) |
|
|
347
|
+
| 0o077 | 0o600 (rw-------) | 0o700 (rwx------) |
|
|
348
|
+
| 0o277 | 0o400 (r--------) | 0o500 (r-x------) |
|
|
337
349
|
|
|
338
350
|
#### String encoding
|
|
339
351
|
|