pwd-fs 2.2.0 → 2.4.1
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/.travis.yml +3 -0
- package/appveyor.yml +3 -0
- package/lib/src/index.d.ts +1 -0
- package/lib/src/index.js +0 -2
- package/lib/src/recurse-io-sync.js +0 -1
- package/lib/src/recurse-io.js +0 -1
- package/lib/test/append.spec.js +7 -8
- package/lib/test/bitmask.spec.js +10 -11
- package/lib/test/chmod.spec.js +9 -10
- package/lib/test/chown.spec.js +9 -10
- package/lib/test/constructor.spec.js +3 -4
- package/lib/test/copy.spec.js +12 -13
- package/lib/test/mkdir.spec.js +13 -14
- package/lib/test/read.spec.js +10 -11
- package/lib/test/readdir.spec.js +5 -6
- package/lib/test/remove.spec.js +7 -8
- package/lib/test/rename.spec.js +9 -10
- package/lib/test/stat.spec.js +11 -12
- package/lib/test/symlink.spec.js +11 -12
- package/lib/test/test.spec.js +10 -11
- package/lib/test/write.spec.js +12 -13
- package/package.json +8 -9
- package/readme.md +7 -6
- package/src/index.ts +0 -2
- package/tsconfig.json +2 -2
package/lib/test/readdir.spec.js
CHANGED
|
@@ -11,7 +11,7 @@ const src_1 = __importDefault(require("../src"));
|
|
|
11
11
|
describe('readdir(src[, options])', () => {
|
|
12
12
|
beforeEach(() => {
|
|
13
13
|
const chance = new chance_1.default();
|
|
14
|
-
mock_fs_1.default({
|
|
14
|
+
(0, mock_fs_1.default)({
|
|
15
15
|
'tmpdir': {
|
|
16
16
|
'binapp': chance.string(),
|
|
17
17
|
'libxbase': mock_fs_1.default.directory()
|
|
@@ -47,7 +47,7 @@ describe('readdir(src[, options])', () => {
|
|
|
47
47
|
await pfs.readdir(`./tmpdir/binapp`);
|
|
48
48
|
}
|
|
49
49
|
catch (err) {
|
|
50
|
-
assert_1.default(err.errno === -20);
|
|
50
|
+
(0, assert_1.default)(err.errno === -20);
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
it('Negative: Throw if not exists resource', async () => {
|
|
@@ -58,7 +58,7 @@ describe('readdir(src[, options])', () => {
|
|
|
58
58
|
await pfs.readdir(`./${base}`);
|
|
59
59
|
}
|
|
60
60
|
catch (err) {
|
|
61
|
-
assert_1.default(err.errno === -2);
|
|
61
|
+
(0, assert_1.default)(err.errno === -2);
|
|
62
62
|
}
|
|
63
63
|
});
|
|
64
64
|
describe('sync mode', () => {
|
|
@@ -92,7 +92,7 @@ describe('readdir(src[, options])', () => {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
catch (err) {
|
|
95
|
-
assert_1.default(err.errno === -20);
|
|
95
|
+
(0, assert_1.default)(err.errno === -20);
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
it(`Negative: Throw if not exists resource`, async () => {
|
|
@@ -105,9 +105,8 @@ describe('readdir(src[, options])', () => {
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
catch (err) {
|
|
108
|
-
assert_1.default(err.errno === -2);
|
|
108
|
+
(0, assert_1.default)(err.errno === -2);
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
|
-
//# sourceMappingURL=readdir.spec.js.map
|
package/lib/test/remove.spec.js
CHANGED
|
@@ -11,7 +11,7 @@ const src_1 = __importDefault(require("../src"));
|
|
|
11
11
|
describe('remove(src [, options])', () => {
|
|
12
12
|
beforeEach(() => {
|
|
13
13
|
const chance = new chance_1.default();
|
|
14
|
-
mock_fs_1.default({
|
|
14
|
+
(0, mock_fs_1.default)({
|
|
15
15
|
'tmpdir': {
|
|
16
16
|
'binapp': chance.string(),
|
|
17
17
|
'libxbase': mock_fs_1.default.directory()
|
|
@@ -26,7 +26,7 @@ describe('remove(src [, options])', () => {
|
|
|
26
26
|
const pfs = new src_1.default();
|
|
27
27
|
await pfs.remove('./tmpdir');
|
|
28
28
|
const exist = await pfs.test('./tmpdir');
|
|
29
|
-
assert_1.default(exist === false);
|
|
29
|
+
(0, assert_1.default)(exist === false);
|
|
30
30
|
});
|
|
31
31
|
it('Positive: Removal a directory with a file, when path is absolute', async () => {
|
|
32
32
|
const pfs = new src_1.default();
|
|
@@ -35,7 +35,7 @@ describe('remove(src [, options])', () => {
|
|
|
35
35
|
resolve: false
|
|
36
36
|
});
|
|
37
37
|
const exist = await pfs.test('./tmpdir');
|
|
38
|
-
assert_1.default(exist === false);
|
|
38
|
+
(0, assert_1.default)(exist === false);
|
|
39
39
|
});
|
|
40
40
|
it('Negative: Throw if not exists resource', async () => {
|
|
41
41
|
const pfs = new src_1.default();
|
|
@@ -45,7 +45,7 @@ describe('remove(src [, options])', () => {
|
|
|
45
45
|
await pfs.remove(`./${base}`);
|
|
46
46
|
}
|
|
47
47
|
catch (err) {
|
|
48
|
-
assert_1.default(err.errno === -2);
|
|
48
|
+
(0, assert_1.default)(err.errno === -2);
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
describe('sync mode', () => {
|
|
@@ -55,7 +55,7 @@ describe('remove(src [, options])', () => {
|
|
|
55
55
|
sync: true
|
|
56
56
|
});
|
|
57
57
|
const exist = await pfs.test('./tmpdir');
|
|
58
|
-
assert_1.default(exist === false);
|
|
58
|
+
(0, assert_1.default)(exist === false);
|
|
59
59
|
});
|
|
60
60
|
it('Positive: Removal a directory with a file, when path is absolute', async () => {
|
|
61
61
|
const pfs = new src_1.default();
|
|
@@ -65,7 +65,7 @@ describe('remove(src [, options])', () => {
|
|
|
65
65
|
resolve: false
|
|
66
66
|
});
|
|
67
67
|
const exist = await pfs.test('./tmpdir');
|
|
68
|
-
assert_1.default(exist === false);
|
|
68
|
+
(0, assert_1.default)(exist === false);
|
|
69
69
|
});
|
|
70
70
|
it('Negative: Throw if not exists resource', async () => {
|
|
71
71
|
const pfs = new src_1.default();
|
|
@@ -77,9 +77,8 @@ describe('remove(src [, options])', () => {
|
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
79
|
catch (err) {
|
|
80
|
-
assert_1.default(err.errno === -2);
|
|
80
|
+
(0, assert_1.default)(err.errno === -2);
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
});
|
|
84
84
|
});
|
|
85
|
-
//# sourceMappingURL=remove.spec.js.map
|
package/lib/test/rename.spec.js
CHANGED
|
@@ -11,7 +11,7 @@ const src_1 = __importDefault(require("../src"));
|
|
|
11
11
|
describe('rename(src, use [, options])', () => {
|
|
12
12
|
beforeEach(() => {
|
|
13
13
|
const chance = new chance_1.default();
|
|
14
|
-
mock_fs_1.default({
|
|
14
|
+
(0, mock_fs_1.default)({
|
|
15
15
|
'tmpdir': {
|
|
16
16
|
'binapp': chance.string(),
|
|
17
17
|
'libxbase': mock_fs_1.default.directory()
|
|
@@ -26,13 +26,13 @@ describe('rename(src, use [, options])', () => {
|
|
|
26
26
|
const pfs = new src_1.default();
|
|
27
27
|
await pfs.rename('./tmpdir/binapp', './tmpdir/newapp');
|
|
28
28
|
const exist = await pfs.test('./tmpdir/newapp');
|
|
29
|
-
assert_1.default(exist);
|
|
29
|
+
(0, assert_1.default)(exist);
|
|
30
30
|
});
|
|
31
31
|
it('Positive: Must be recursive rename directory', async () => {
|
|
32
32
|
const pfs = new src_1.default();
|
|
33
33
|
await pfs.rename('./tmpdir/libxbase', './tmpdir/newxbase');
|
|
34
34
|
const exist = await pfs.test('./tmpdir/newxbase');
|
|
35
|
-
assert_1.default(exist);
|
|
35
|
+
(0, assert_1.default)(exist);
|
|
36
36
|
});
|
|
37
37
|
it('Positive: Must be recursive rename directory, when path is absolute', async () => {
|
|
38
38
|
const pfs = new src_1.default();
|
|
@@ -41,7 +41,7 @@ describe('rename(src, use [, options])', () => {
|
|
|
41
41
|
resolve: false
|
|
42
42
|
});
|
|
43
43
|
const exist = await pfs.test('./newxbase');
|
|
44
|
-
assert_1.default(exist);
|
|
44
|
+
(0, assert_1.default)(exist);
|
|
45
45
|
});
|
|
46
46
|
it('Negative: Throw if not exists resource', async () => {
|
|
47
47
|
const pfs = new src_1.default();
|
|
@@ -51,7 +51,7 @@ describe('rename(src, use [, options])', () => {
|
|
|
51
51
|
await pfs.rename(`./${base}`, './tmpdir/newapp');
|
|
52
52
|
}
|
|
53
53
|
catch (err) {
|
|
54
|
-
assert_1.default(err.errno === -2);
|
|
54
|
+
(0, assert_1.default)(err.errno === -2);
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
describe('sync mode', () => {
|
|
@@ -61,7 +61,7 @@ describe('rename(src, use [, options])', () => {
|
|
|
61
61
|
sync: true
|
|
62
62
|
});
|
|
63
63
|
const exist = await pfs.test('./tmpdir/newapp');
|
|
64
|
-
assert_1.default(exist);
|
|
64
|
+
(0, assert_1.default)(exist);
|
|
65
65
|
});
|
|
66
66
|
it('Positive: Must be recursive rename directory', async () => {
|
|
67
67
|
const pfs = new src_1.default();
|
|
@@ -69,7 +69,7 @@ describe('rename(src, use [, options])', () => {
|
|
|
69
69
|
sync: true
|
|
70
70
|
});
|
|
71
71
|
const exist = await pfs.test('./tmpdir/newxbase');
|
|
72
|
-
assert_1.default(exist);
|
|
72
|
+
(0, assert_1.default)(exist);
|
|
73
73
|
});
|
|
74
74
|
it('Positive: Must be recursive rename directory, when path is absolute', async () => {
|
|
75
75
|
const pfs = new src_1.default();
|
|
@@ -79,7 +79,7 @@ describe('rename(src, use [, options])', () => {
|
|
|
79
79
|
resolve: false
|
|
80
80
|
});
|
|
81
81
|
const exist = await pfs.test('./newxbase');
|
|
82
|
-
assert_1.default(exist);
|
|
82
|
+
(0, assert_1.default)(exist);
|
|
83
83
|
});
|
|
84
84
|
it('Negative: Throw if not exists resource', async () => {
|
|
85
85
|
const pfs = new src_1.default();
|
|
@@ -91,9 +91,8 @@ describe('rename(src, use [, options])', () => {
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
catch (err) {
|
|
94
|
-
assert_1.default(err.errno === -2);
|
|
94
|
+
(0, assert_1.default)(err.errno === -2);
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
|
-
//# sourceMappingURL=rename.spec.js.map
|
package/lib/test/stat.spec.js
CHANGED
|
@@ -11,7 +11,7 @@ const src_1 = __importDefault(require("../src"));
|
|
|
11
11
|
describe('stat(src [, options])', () => {
|
|
12
12
|
beforeEach(() => {
|
|
13
13
|
const chance = new chance_1.default();
|
|
14
|
-
mock_fs_1.default({
|
|
14
|
+
(0, mock_fs_1.default)({
|
|
15
15
|
'tmpdir': {
|
|
16
16
|
'binapp': chance.string(),
|
|
17
17
|
'libxbase': mock_fs_1.default.directory()
|
|
@@ -25,17 +25,17 @@ describe('stat(src [, options])', () => {
|
|
|
25
25
|
it('Positive: Must return information a file', async () => {
|
|
26
26
|
const pfs = new src_1.default();
|
|
27
27
|
const stats = await pfs.stat('./tmpdir/binapp');
|
|
28
|
-
assert_1.default(stats.isFile());
|
|
28
|
+
(0, assert_1.default)(stats.isFile());
|
|
29
29
|
});
|
|
30
30
|
it('Positive: Must return information a directory', async () => {
|
|
31
31
|
const pfs = new src_1.default();
|
|
32
32
|
const stats = await pfs.stat('./tmpdir/libxbase');
|
|
33
|
-
assert_1.default(stats.isDirectory());
|
|
33
|
+
(0, assert_1.default)(stats.isDirectory());
|
|
34
34
|
});
|
|
35
35
|
it('Positive: Must return information a symlink', async () => {
|
|
36
36
|
const pfs = new src_1.default();
|
|
37
37
|
const stats = await pfs.stat('./flexapp');
|
|
38
|
-
assert_1.default(stats.isSymbolicLink());
|
|
38
|
+
(0, assert_1.default)(stats.isSymbolicLink());
|
|
39
39
|
});
|
|
40
40
|
it('Positive: Must return stats information, when path is absolute', async () => {
|
|
41
41
|
const pfs = new src_1.default();
|
|
@@ -43,7 +43,7 @@ describe('stat(src [, options])', () => {
|
|
|
43
43
|
const stats = await pfs.stat(`${cwd}${path_1.sep}tmpdir`, {
|
|
44
44
|
resolve: false
|
|
45
45
|
});
|
|
46
|
-
assert_1.default(stats.isDirectory());
|
|
46
|
+
(0, assert_1.default)(stats.isDirectory());
|
|
47
47
|
});
|
|
48
48
|
it('Negative: Throw if not exists resource', async () => {
|
|
49
49
|
const pfs = new src_1.default();
|
|
@@ -53,7 +53,7 @@ describe('stat(src [, options])', () => {
|
|
|
53
53
|
await pfs.stat(`./${base}`);
|
|
54
54
|
}
|
|
55
55
|
catch (err) {
|
|
56
|
-
assert_1.default(err.errno === -2);
|
|
56
|
+
(0, assert_1.default)(err.errno === -2);
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
describe('sync mode', () => {
|
|
@@ -62,21 +62,21 @@ describe('stat(src [, options])', () => {
|
|
|
62
62
|
const stats = pfs.stat('./tmpdir/binapp', {
|
|
63
63
|
sync: true
|
|
64
64
|
});
|
|
65
|
-
assert_1.default(stats.isFile());
|
|
65
|
+
(0, assert_1.default)(stats.isFile());
|
|
66
66
|
});
|
|
67
67
|
it('Positive: Must return information a directory in ', async () => {
|
|
68
68
|
const pfs = new src_1.default();
|
|
69
69
|
const stats = pfs.stat('./tmpdir/libxbase', {
|
|
70
70
|
sync: true
|
|
71
71
|
});
|
|
72
|
-
assert_1.default(stats.isDirectory());
|
|
72
|
+
(0, assert_1.default)(stats.isDirectory());
|
|
73
73
|
});
|
|
74
74
|
it('Positive: Must return information a symlink', async () => {
|
|
75
75
|
const pfs = new src_1.default();
|
|
76
76
|
const stats = pfs.stat('./flexapp', {
|
|
77
77
|
sync: true
|
|
78
78
|
});
|
|
79
|
-
assert_1.default(stats.isSymbolicLink());
|
|
79
|
+
(0, assert_1.default)(stats.isSymbolicLink());
|
|
80
80
|
});
|
|
81
81
|
it('Positive: Must return stats information, when path is absolute', async () => {
|
|
82
82
|
const pfs = new src_1.default();
|
|
@@ -85,7 +85,7 @@ describe('stat(src [, options])', () => {
|
|
|
85
85
|
sync: true,
|
|
86
86
|
resolve: false
|
|
87
87
|
});
|
|
88
|
-
assert_1.default(stats.isDirectory());
|
|
88
|
+
(0, assert_1.default)(stats.isDirectory());
|
|
89
89
|
});
|
|
90
90
|
it('Negative: Throw if not exists resource', async () => {
|
|
91
91
|
const pfs = new src_1.default();
|
|
@@ -97,9 +97,8 @@ describe('stat(src [, options])', () => {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
catch (err) {
|
|
100
|
-
assert_1.default(err.errno === -2);
|
|
100
|
+
(0, assert_1.default)(err.errno === -2);
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
|
-
//# sourceMappingURL=stat.spec.js.map
|
package/lib/test/symlink.spec.js
CHANGED
|
@@ -11,7 +11,7 @@ const src_1 = __importDefault(require("../src"));
|
|
|
11
11
|
describe('symlink(src, use [, options])', () => {
|
|
12
12
|
beforeEach(() => {
|
|
13
13
|
const chance = new chance_1.default();
|
|
14
|
-
mock_fs_1.default({
|
|
14
|
+
(0, mock_fs_1.default)({
|
|
15
15
|
'tmpdir': {
|
|
16
16
|
'binapp': chance.string(),
|
|
17
17
|
'libxbase': mock_fs_1.default.directory()
|
|
@@ -26,13 +26,13 @@ describe('symlink(src, use [, options])', () => {
|
|
|
26
26
|
const pfs = new src_1.default();
|
|
27
27
|
await pfs.symlink('./tmpdir/binapp', './linkapp');
|
|
28
28
|
const stats = await pfs.stat('./linkapp');
|
|
29
|
-
assert_1.default(stats.isSymbolicLink());
|
|
29
|
+
(0, assert_1.default)(stats.isSymbolicLink());
|
|
30
30
|
});
|
|
31
31
|
it('Positive: Must be created a symbolic link for directory', async () => {
|
|
32
32
|
const pfs = new src_1.default();
|
|
33
33
|
await pfs.symlink(`./tmpdir/libxbase`, './linkapp');
|
|
34
34
|
const stats = await pfs.stat('./linkapp');
|
|
35
|
-
assert_1.default(stats.isSymbolicLink());
|
|
35
|
+
(0, assert_1.default)(stats.isSymbolicLink());
|
|
36
36
|
});
|
|
37
37
|
it('Positive: Must be created a symbolic, when path is absolute', async () => {
|
|
38
38
|
const pfs = new src_1.default();
|
|
@@ -41,7 +41,7 @@ describe('symlink(src, use [, options])', () => {
|
|
|
41
41
|
resolve: false
|
|
42
42
|
});
|
|
43
43
|
const stats = await pfs.stat('./linkapp');
|
|
44
|
-
assert_1.default(stats.isSymbolicLink());
|
|
44
|
+
(0, assert_1.default)(stats.isSymbolicLink());
|
|
45
45
|
});
|
|
46
46
|
it('Negative: Throw if destination already exists', async () => {
|
|
47
47
|
const pfs = new src_1.default();
|
|
@@ -49,7 +49,7 @@ describe('symlink(src, use [, options])', () => {
|
|
|
49
49
|
await pfs.symlink(`./flexapp`, './tmpdir/binapp');
|
|
50
50
|
}
|
|
51
51
|
catch (err) {
|
|
52
|
-
assert_1.default(err.errno === -17);
|
|
52
|
+
(0, assert_1.default)(err.errno === -17);
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
it('Negative: Throw if not exists resource', async () => {
|
|
@@ -60,7 +60,7 @@ describe('symlink(src, use [, options])', () => {
|
|
|
60
60
|
await pfs.symlink(`./${base}`, './linkapp');
|
|
61
61
|
}
|
|
62
62
|
catch (err) {
|
|
63
|
-
assert_1.default(err.errno === -2);
|
|
63
|
+
(0, assert_1.default)(err.errno === -2);
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
describe('sync mode', () => {
|
|
@@ -70,7 +70,7 @@ describe('symlink(src, use [, options])', () => {
|
|
|
70
70
|
sync: true
|
|
71
71
|
});
|
|
72
72
|
const stats = await pfs.stat('./linkapp');
|
|
73
|
-
assert_1.default(stats.isSymbolicLink());
|
|
73
|
+
(0, assert_1.default)(stats.isSymbolicLink());
|
|
74
74
|
});
|
|
75
75
|
it('Positive: Must be created a symbolic link for directory', async () => {
|
|
76
76
|
const pfs = new src_1.default();
|
|
@@ -78,7 +78,7 @@ describe('symlink(src, use [, options])', () => {
|
|
|
78
78
|
sync: true
|
|
79
79
|
});
|
|
80
80
|
const stats = await pfs.stat('./linkapp');
|
|
81
|
-
assert_1.default(stats.isSymbolicLink());
|
|
81
|
+
(0, assert_1.default)(stats.isSymbolicLink());
|
|
82
82
|
});
|
|
83
83
|
it('Positive: Must be created a symbolic, when path is absolute', async () => {
|
|
84
84
|
const pfs = new src_1.default();
|
|
@@ -88,7 +88,7 @@ describe('symlink(src, use [, options])', () => {
|
|
|
88
88
|
resolve: false
|
|
89
89
|
});
|
|
90
90
|
const stats = await pfs.stat('./linkapp');
|
|
91
|
-
assert_1.default(stats.isSymbolicLink());
|
|
91
|
+
(0, assert_1.default)(stats.isSymbolicLink());
|
|
92
92
|
});
|
|
93
93
|
it('Negative: Throw if destination already exists', async () => {
|
|
94
94
|
const pfs = new src_1.default();
|
|
@@ -98,7 +98,7 @@ describe('symlink(src, use [, options])', () => {
|
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
catch (err) {
|
|
101
|
-
assert_1.default(err.errno === -17);
|
|
101
|
+
(0, assert_1.default)(err.errno === -17);
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
it('Negative: Throw if not exists resource', async () => {
|
|
@@ -111,9 +111,8 @@ describe('symlink(src, use [, options])', () => {
|
|
|
111
111
|
});
|
|
112
112
|
}
|
|
113
113
|
catch (err) {
|
|
114
|
-
assert_1.default(err.errno === -2);
|
|
114
|
+
(0, assert_1.default)(err.errno === -2);
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
117
|
});
|
|
118
118
|
});
|
|
119
|
-
//# sourceMappingURL=symlink.spec.js.map
|
package/lib/test/test.spec.js
CHANGED
|
@@ -11,7 +11,7 @@ const src_1 = __importDefault(require("../src"));
|
|
|
11
11
|
describe('test(src[, options])', () => {
|
|
12
12
|
beforeEach(() => {
|
|
13
13
|
const chance = new chance_1.default();
|
|
14
|
-
mock_fs_1.default({
|
|
14
|
+
(0, mock_fs_1.default)({
|
|
15
15
|
'tmpdir': {
|
|
16
16
|
'binapp': chance.string(),
|
|
17
17
|
'libxbase': mock_fs_1.default.directory()
|
|
@@ -25,24 +25,24 @@ describe('test(src[, options])', () => {
|
|
|
25
25
|
it(`Positive: Should return 'true' for current working directory`, async () => {
|
|
26
26
|
const pfs = new src_1.default();
|
|
27
27
|
const exist = await pfs.test('.');
|
|
28
|
-
assert_1.default(exist);
|
|
28
|
+
(0, assert_1.default)(exist);
|
|
29
29
|
});
|
|
30
30
|
it(`Positive: For existing directory should return 'true'`, async () => {
|
|
31
31
|
const pfs = new src_1.default();
|
|
32
32
|
const exist = await pfs.test('./tmpdir/libxbase');
|
|
33
|
-
assert_1.default(exist);
|
|
33
|
+
(0, assert_1.default)(exist);
|
|
34
34
|
});
|
|
35
35
|
it(`Positive: For existing file should return 'true'`, async () => {
|
|
36
36
|
const pfs = new src_1.default();
|
|
37
37
|
const exist = await pfs.test('./tmpdir/binapp');
|
|
38
|
-
assert_1.default(exist);
|
|
38
|
+
(0, assert_1.default)(exist);
|
|
39
39
|
});
|
|
40
40
|
it(`Positive: A non-existent file must return 'false'`, async () => {
|
|
41
41
|
const pfs = new src_1.default();
|
|
42
42
|
const chance = new chance_1.default();
|
|
43
43
|
const base = chance.guid();
|
|
44
44
|
const exists = await pfs.test(`./${base}`);
|
|
45
|
-
assert_1.default(exists === false);
|
|
45
|
+
(0, assert_1.default)(exists === false);
|
|
46
46
|
});
|
|
47
47
|
it(`Positive: Should return 'true' for absolute source`, async () => {
|
|
48
48
|
const pfs = new src_1.default();
|
|
@@ -50,7 +50,7 @@ describe('test(src[, options])', () => {
|
|
|
50
50
|
const exists = await pfs.test(`${cwd}${path_1.sep}tmpdir`, {
|
|
51
51
|
resolve: false
|
|
52
52
|
});
|
|
53
|
-
assert_1.default(exists);
|
|
53
|
+
(0, assert_1.default)(exists);
|
|
54
54
|
});
|
|
55
55
|
describe('sync mode', () => {
|
|
56
56
|
it(`Positive: For existing directory should return 'true'`, () => {
|
|
@@ -58,14 +58,14 @@ describe('test(src[, options])', () => {
|
|
|
58
58
|
const exist = pfs.test('./tmpdir/libxbase', {
|
|
59
59
|
sync: true
|
|
60
60
|
});
|
|
61
|
-
assert_1.default(exist);
|
|
61
|
+
(0, assert_1.default)(exist);
|
|
62
62
|
});
|
|
63
63
|
it(`Positive: For existing file should return 'true'`, () => {
|
|
64
64
|
const pfs = new src_1.default();
|
|
65
65
|
const exist = pfs.test('./tmpdir/binapp', {
|
|
66
66
|
sync: true
|
|
67
67
|
});
|
|
68
|
-
assert_1.default(exist);
|
|
68
|
+
(0, assert_1.default)(exist);
|
|
69
69
|
});
|
|
70
70
|
it(`Positive: A non-existent file must return 'false'`, async () => {
|
|
71
71
|
const pfs = new src_1.default();
|
|
@@ -74,7 +74,7 @@ describe('test(src[, options])', () => {
|
|
|
74
74
|
const exists = pfs.test(`./${base}`, {
|
|
75
75
|
sync: true
|
|
76
76
|
});
|
|
77
|
-
assert_1.default(exists === false);
|
|
77
|
+
(0, assert_1.default)(exists === false);
|
|
78
78
|
});
|
|
79
79
|
it(`Positive: Should return 'true' for absolute source`, async () => {
|
|
80
80
|
const pfs = new src_1.default();
|
|
@@ -83,8 +83,7 @@ describe('test(src[, options])', () => {
|
|
|
83
83
|
sync: true,
|
|
84
84
|
resolve: false
|
|
85
85
|
});
|
|
86
|
-
assert_1.default(exists);
|
|
86
|
+
(0, assert_1.default)(exists);
|
|
87
87
|
});
|
|
88
88
|
});
|
|
89
89
|
});
|
|
90
|
-
//# sourceMappingURL=test.spec.js.map
|
package/lib/test/write.spec.js
CHANGED
|
@@ -11,7 +11,7 @@ const src_1 = __importDefault(require("../src"));
|
|
|
11
11
|
describe('write(src, data[, options])', () => {
|
|
12
12
|
beforeEach(() => {
|
|
13
13
|
const chance = new chance_1.default();
|
|
14
|
-
mock_fs_1.default({
|
|
14
|
+
(0, mock_fs_1.default)({
|
|
15
15
|
'tmpdir': {
|
|
16
16
|
'binapp': chance.string(),
|
|
17
17
|
'libxbase': mock_fs_1.default.directory()
|
|
@@ -27,11 +27,11 @@ describe('write(src, data[, options])', () => {
|
|
|
27
27
|
const chance = new chance_1.default();
|
|
28
28
|
const base = chance.guid();
|
|
29
29
|
const exists = await pfs.test(`./tmpdir/${base}`);
|
|
30
|
-
assert_1.default(exists === false);
|
|
30
|
+
(0, assert_1.default)(exists === false);
|
|
31
31
|
const payload = chance.paragraph();
|
|
32
32
|
await pfs.write(`./tmpdir/${base}`, payload);
|
|
33
33
|
const stats = await pfs.stat(`./tmpdir/${base}`);
|
|
34
|
-
assert_1.default(stats.size > 0);
|
|
34
|
+
(0, assert_1.default)(stats.size > 0);
|
|
35
35
|
});
|
|
36
36
|
it('Positive: Must rewrite content if file already exists', async () => {
|
|
37
37
|
const pfs = new src_1.default();
|
|
@@ -39,7 +39,7 @@ describe('write(src, data[, options])', () => {
|
|
|
39
39
|
const payload = chance.paragraph();
|
|
40
40
|
await pfs.write('./tmpdir/binapp', payload);
|
|
41
41
|
const stats = await pfs.stat(`./tmpdir/binapp`);
|
|
42
|
-
assert_1.default(stats.size > 0);
|
|
42
|
+
(0, assert_1.default)(stats.size > 0);
|
|
43
43
|
});
|
|
44
44
|
it(`Positive: Must write content to file, when path is absolute`, async () => {
|
|
45
45
|
const pfs = new src_1.default();
|
|
@@ -50,7 +50,7 @@ describe('write(src, data[, options])', () => {
|
|
|
50
50
|
resolve: false
|
|
51
51
|
});
|
|
52
52
|
const stats = await pfs.stat(`./tmpdir/binapp`);
|
|
53
|
-
assert_1.default(stats.size > 0);
|
|
53
|
+
(0, assert_1.default)(stats.size > 0);
|
|
54
54
|
});
|
|
55
55
|
it('Negative: Throw if resource is directory', async () => {
|
|
56
56
|
const pfs = new src_1.default();
|
|
@@ -60,7 +60,7 @@ describe('write(src, data[, options])', () => {
|
|
|
60
60
|
await pfs.write('./tmpdir/libxbase', payload);
|
|
61
61
|
}
|
|
62
62
|
catch (err) {
|
|
63
|
-
assert_1.default(err.errno === -21);
|
|
63
|
+
(0, assert_1.default)(err.errno === -21);
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
it(`Negative: Unexpected option 'flag' returns Error`, async () => {
|
|
@@ -73,7 +73,7 @@ describe('write(src, data[, options])', () => {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
catch (err) {
|
|
76
|
-
assert_1.default(err.errno === -9);
|
|
76
|
+
(0, assert_1.default)(err.errno === -9);
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
describe('sync mode', () => {
|
|
@@ -82,13 +82,13 @@ describe('write(src, data[, options])', () => {
|
|
|
82
82
|
const chance = new chance_1.default();
|
|
83
83
|
const base = chance.guid();
|
|
84
84
|
const exists = await pfs.test(`./tmpdir/${base}`);
|
|
85
|
-
assert_1.default(exists === false);
|
|
85
|
+
(0, assert_1.default)(exists === false);
|
|
86
86
|
const payload = chance.paragraph();
|
|
87
87
|
pfs.write(`./tmpdir/${base}`, payload, {
|
|
88
88
|
sync: true
|
|
89
89
|
});
|
|
90
90
|
const stats = await pfs.stat(`./tmpdir/${base}`);
|
|
91
|
-
assert_1.default(stats.size > 0);
|
|
91
|
+
(0, assert_1.default)(stats.size > 0);
|
|
92
92
|
});
|
|
93
93
|
it(`Positive: Must write content to file, when path is absolute`, async () => {
|
|
94
94
|
const pfs = new src_1.default();
|
|
@@ -100,7 +100,7 @@ describe('write(src, data[, options])', () => {
|
|
|
100
100
|
resolve: false
|
|
101
101
|
});
|
|
102
102
|
const stats = await pfs.stat(`./tmpdir/binapp`);
|
|
103
|
-
assert_1.default(stats.size > 0);
|
|
103
|
+
(0, assert_1.default)(stats.size > 0);
|
|
104
104
|
});
|
|
105
105
|
it('Negative: Throw if resource is directory', async () => {
|
|
106
106
|
const pfs = new src_1.default();
|
|
@@ -112,7 +112,7 @@ describe('write(src, data[, options])', () => {
|
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
catch (err) {
|
|
115
|
-
assert_1.default(err.errno === -21);
|
|
115
|
+
(0, assert_1.default)(err.errno === -21);
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
it(`Negative: Unexpected option 'flag' returns Error`, async () => {
|
|
@@ -126,9 +126,8 @@ describe('write(src, data[, options])', () => {
|
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
catch (err) {
|
|
129
|
-
assert_1.default(err.errno === -9);
|
|
129
|
+
(0, assert_1.default)(err.errno === -9);
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
});
|
|
133
133
|
});
|
|
134
|
-
//# sourceMappingURL=write.spec.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pwd-fs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "Extend the file system the capabilities of declaring the present working directory and recursive execution",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"umask",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
"remove",
|
|
15
15
|
"read",
|
|
16
16
|
"write",
|
|
17
|
-
"append",
|
|
18
17
|
"readdir",
|
|
19
18
|
"mkdir"
|
|
20
19
|
],
|
|
@@ -37,14 +36,14 @@
|
|
|
37
36
|
"test": "mocha ./lib/test"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
|
-
"@tsconfig/
|
|
39
|
+
"@tsconfig/node16": "^1.0.3",
|
|
41
40
|
"@types/chance": "^1.1.1",
|
|
42
|
-
"@types/mocha": "^
|
|
41
|
+
"@types/mocha": "^10.0.0",
|
|
43
42
|
"@types/mock-fs": "^4.13.0",
|
|
44
|
-
"@types/node": "^
|
|
45
|
-
"chance": "^1.1.
|
|
46
|
-
"mocha": "^
|
|
47
|
-
"mock-fs": "^
|
|
48
|
-
"typescript": "^4.
|
|
43
|
+
"@types/node": "^18.11.9",
|
|
44
|
+
"chance": "^1.1.9",
|
|
45
|
+
"mocha": "^10.1.0",
|
|
46
|
+
"mock-fs": "^5.2.0",
|
|
47
|
+
"typescript": "^4.8.4"
|
|
49
48
|
}
|
|
50
49
|
}
|
package/readme.md
CHANGED
|
@@ -37,7 +37,7 @@ npm i 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)
|
|
40
|
+
* [pfs.append(src, data[, options])](#pfsappendsrc-data-options-colorboxredcolorwhite-deprecated-) $\colorbox{red}{{\color{white}{ deprecated }}}$
|
|
41
41
|
* [pfs.readdir(dir[, options])](#pfsreaddirdir-options)
|
|
42
42
|
* [pfs.mkdir(dir[, options])](#pfsmkdirdir-options)
|
|
43
43
|
* [pfs.pwd](#pfspwd)
|
|
@@ -47,7 +47,7 @@ The scope `URI` of the class methods are divided into groups.
|
|
|
47
47
|
| URI | Methods |
|
|
48
48
|
|-----------------------------|------------------------------------------------------------------|
|
|
49
49
|
| Common (file and directory) | `chmod` `chown` `copy` `remove` `rename` `symlink` `stat` `test` |
|
|
50
|
-
| File only | `
|
|
50
|
+
| File only | `read` `write` |
|
|
51
51
|
| Directory only | `mkdir` `readdir` |
|
|
52
52
|
|
|
53
53
|
|
|
@@ -269,7 +269,8 @@ await pfs.write('./file.txt', '... some text');
|
|
|
269
269
|
|
|
270
270
|
> This function is limited to writing only `string`. For `stream`, `fs.createWriteStream()` is recommended.
|
|
271
271
|
|
|
272
|
-
#### pfs.append(src, data[, options])
|
|
272
|
+
#### pfs.append(src, data[, options]) $\colorbox{red}{{\color{white}{ deprecated }}}$
|
|
273
|
+
|
|
273
274
|
|
|
274
275
|
- `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`.
|
|
275
276
|
- `data` <[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>
|
|
@@ -283,9 +284,9 @@ await pfs.write('./file.txt', '... some text');
|
|
|
283
284
|
|
|
284
285
|
Asynchronously append data to a file, creating the file if it does not yet exist.
|
|
285
286
|
|
|
286
|
-
> NOTE Method is deprecated.
|
|
287
|
+
> NOTE Method is deprecated. May be removed in the next major version
|
|
287
288
|
|
|
288
|
-
**Use
|
|
289
|
+
**Use instead [pfs.write(src, data[, options])](#pfswritesrc-data-options) with { flag: 'a' } option**
|
|
289
290
|
|
|
290
291
|
```ts
|
|
291
292
|
await pfs.write('./file', 'some content', {
|
|
@@ -362,7 +363,7 @@ Encoding | Description
|
|
|
362
363
|
|
|
363
364
|
#### File system flags
|
|
364
365
|
|
|
365
|
-
The following flags are available for `pfs.read
|
|
366
|
+
The following flags are available for `pfs.read` and `pfs.write` the flag option takes a <[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>.
|
|
366
367
|
|
|
367
368
|
Flag | Description
|
|
368
369
|
-----|------------
|
package/src/index.ts
CHANGED
|
@@ -472,8 +472,6 @@ export default class PoweredFileSystem {
|
|
|
472
472
|
umask?: number,
|
|
473
473
|
flag?: Flag
|
|
474
474
|
} = {}) {
|
|
475
|
-
console.log(`'append' with be removed in the next major version. Use 'write' with { flag: 'a' } option`);
|
|
476
|
-
|
|
477
475
|
if (resolve) {
|
|
478
476
|
src = this.resolve(src);
|
|
479
477
|
}
|