pwd-fs 2.4.2 → 3.1.4
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 +2 -3
- package/appveyor.yml +2 -4
- package/lib/src/index.d.ts +4 -186
- package/lib/src/index.js +18 -294
- package/lib/src/powered-file-system.d.ts +156 -0
- package/lib/src/powered-file-system.js +264 -0
- package/lib/src/recurse-io-sync.d.ts +10 -5
- package/lib/src/recurse-io-sync.js +74 -69
- package/lib/src/recurse-io.d.ts +14 -6
- package/lib/src/recurse-io.js +164 -160
- package/lib/test/__fmock.d.ts +5 -0
- package/lib/test/__fmock.js +40 -0
- package/lib/test/append.spec.js +36 -77
- package/lib/test/bitmask.spec.js +14 -17
- package/lib/test/chmod.spec.js +42 -84
- package/lib/test/chown.spec.js +45 -71
- package/lib/test/constructor.spec.js +7 -10
- package/lib/test/copy.spec.js +53 -108
- package/lib/test/mkdir.spec.js +62 -119
- package/lib/test/read.spec.js +47 -78
- package/lib/test/readdir.spec.js +48 -90
- package/lib/test/remove.spec.js +44 -65
- package/lib/test/rename.spec.js +43 -75
- package/lib/test/stat.spec.js +50 -78
- package/lib/test/symlink.spec.js +51 -95
- package/lib/test/test.spec.js +37 -66
- package/lib/test/write.spec.js +52 -103
- package/package.json +8 -11
- package/readme.md +10 -21
- package/src/index.ts +4 -623
- package/src/powered-file-system.ts +527 -0
- package/src/recurse-io-sync.ts +77 -71
- package/src/recurse-io.ts +181 -176
- package/test/__fmock.ts +45 -0
- package/test/append.spec.ts +44 -98
- package/test/bitmask.spec.ts +14 -17
- package/test/chmod.spec.ts +45 -95
- package/test/chown.spec.ts +61 -93
- package/test/constructor.spec.ts +4 -7
- package/test/copy.spec.ts +72 -142
- package/test/mkdir.spec.ts +87 -153
- package/test/read.spec.ts +64 -103
- package/test/readdir.spec.ts +65 -113
- package/test/remove.spec.ts +58 -82
- package/test/rename.spec.ts +58 -96
- package/test/stat.spec.ts +68 -100
- package/test/symlink.spec.ts +74 -125
- package/test/test.spec.ts +51 -84
- package/test/write.spec.ts +68 -131
- package/tsconfig.json +14 -7
- package/lib/src/index.js.map +0 -1
- package/lib/src/recurse-io-sync.js.map +0 -1
- package/lib/src/recurse-io.js.map +0 -1
- package/lib/test/append.spec.js.map +0 -1
- package/lib/test/bitmask.spec.js.map +0 -1
- package/lib/test/chmod.spec.js.map +0 -1
- package/lib/test/chown.spec.js.map +0 -1
- package/lib/test/constructor.spec.js.map +0 -1
- package/lib/test/copy.spec.js.map +0 -1
- package/lib/test/mkdir.spec.js.map +0 -1
- package/lib/test/read.spec.js.map +0 -1
- package/lib/test/readdir.spec.js.map +0 -1
- package/lib/test/remove.spec.js.map +0 -1
- package/lib/test/rename.spec.js.map +0 -1
- package/lib/test/stat.spec.js.map +0 -1
- package/lib/test/symlink.spec.js.map +0 -1
- package/lib/test/test.spec.js.map +0 -1
- package/lib/test/write.spec.js.map +0 -1
package/test/chmod.spec.ts
CHANGED
|
@@ -1,127 +1,77 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
2
|
-
import
|
|
3
|
-
import mockFs from 'mock-fs';
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import fs from 'node:fs';
|
|
4
3
|
import Chance from 'chance';
|
|
5
|
-
import
|
|
4
|
+
import { expect } from 'expect';
|
|
5
|
+
import { fmock, restore } from './__fmock';
|
|
6
|
+
import { pfs, bitmask } from '../src';
|
|
6
7
|
|
|
7
8
|
describe('chmod(src, mode [, options])', () => {
|
|
8
|
-
|
|
9
|
-
const chance = new Chance();
|
|
9
|
+
const chance = new Chance();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
path: 'tmpdir/binapp'
|
|
18
|
-
})
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
fmock({
|
|
13
|
+
'./tmpdir/tings.txt': {
|
|
14
|
+
type: 'file',
|
|
15
|
+
data: chance.string()
|
|
16
|
+
}
|
|
19
17
|
});
|
|
20
18
|
});
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
restore('./tmpdir');
|
|
22
|
+
});
|
|
21
23
|
|
|
22
|
-
afterEach(mockFs.restore);
|
|
23
24
|
|
|
24
25
|
it('Positive: Changes directory and file permissions', async () => {
|
|
25
|
-
const pfs = new PoweredFileSystem();
|
|
26
|
-
|
|
27
26
|
await pfs.chmod('./tmpdir', 0o744);
|
|
28
27
|
|
|
29
|
-
const { mode } =
|
|
30
|
-
const umask =
|
|
28
|
+
const { mode } = fs.lstatSync('./tmpdir/tings.txt');
|
|
29
|
+
const umask = bitmask(mode);
|
|
31
30
|
|
|
32
31
|
assert(umask === 0o744);
|
|
33
32
|
});
|
|
34
33
|
|
|
35
|
-
it('Positive: Must be changes directory when path is absolute', async () => {
|
|
36
|
-
const pfs = new PoweredFileSystem();
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
await
|
|
40
|
-
|
|
35
|
+
it('Negative: Throw if not exists resource', async () => {
|
|
36
|
+
await expect(async () => {
|
|
37
|
+
await pfs.chmod('./non-existent-source', 0o744);
|
|
38
|
+
})
|
|
39
|
+
.rejects
|
|
40
|
+
.toThrow();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
it(`[sync] Positive: Changes permissions of directory`, () => {
|
|
45
|
+
pfs.chmod('./tmpdir', 0o744, {
|
|
46
|
+
sync: true
|
|
41
47
|
});
|
|
42
48
|
|
|
43
|
-
const { mode } =
|
|
44
|
-
const umask =
|
|
49
|
+
const { mode } = fs.lstatSync('./tmpdir');
|
|
50
|
+
const umask = bitmask(mode);
|
|
45
51
|
|
|
46
52
|
assert(umask === 0o744);
|
|
47
53
|
});
|
|
48
54
|
|
|
49
|
-
it('Negative: Search permission is denied on a component of the path prefix', async () => {
|
|
50
|
-
const pfs = new PoweredFileSystem();
|
|
51
55
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
assert(err.errno === -9);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
56
|
+
it(`[sync] Positive: Changes file permissions`, () => {
|
|
57
|
+
pfs.chmod('./tmpdir', 0o744, {
|
|
58
|
+
sync: true
|
|
59
|
+
});
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
const
|
|
61
|
+
const { mode } = fs.lstatSync('./tmpdir/tings.txt');
|
|
62
|
+
const umask = bitmask(mode);
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
await pfs.chmod('./non-existent-source', 0o744);
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
assert(err.errno === -2);
|
|
68
|
-
}
|
|
64
|
+
assert(umask === 0o744);
|
|
69
65
|
});
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
it('[sync] Negative: Throw if not exists resource', () => {
|
|
69
|
+
const guid = chance.guid();
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const pfs = new PoweredFileSystem();
|
|
74
|
-
|
|
75
|
-
pfs.chmod('./tmpdir', 0o744, {
|
|
71
|
+
assert.throws(() => {
|
|
72
|
+
pfs.chmod(`./${guid}`, 0o744, {
|
|
76
73
|
sync: true
|
|
77
74
|
});
|
|
78
|
-
|
|
79
|
-
const { mode } = await pfs.stat('./tmpdir/binapp');
|
|
80
|
-
const umask = PoweredFileSystem.bitmask(mode);
|
|
81
|
-
|
|
82
|
-
assert(umask === 0o744);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('Positive: Must be changes directory when path is absolute', async () => {
|
|
86
|
-
const pfs = new PoweredFileSystem();
|
|
87
|
-
|
|
88
|
-
const cwd = process.cwd();
|
|
89
|
-
|
|
90
|
-
pfs.chmod(`${cwd}${sep}tmpdir${sep}libxbase` , 0o744, {
|
|
91
|
-
sync: true,
|
|
92
|
-
resolve: false
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
const { mode } = await pfs.stat('./tmpdir/libxbase');
|
|
96
|
-
const umask = PoweredFileSystem.bitmask(mode);
|
|
97
|
-
|
|
98
|
-
assert(umask === 0o744);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('Negative: Search permission is denied on a component of the path prefix', async () => {
|
|
102
|
-
const pfs = new PoweredFileSystem();
|
|
103
|
-
|
|
104
|
-
try {
|
|
105
|
-
pfs.chmod('./tmpdir', 0, {
|
|
106
|
-
sync: true
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
catch (err) {
|
|
110
|
-
assert(err.errno === -9);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('Negative: Throw if not exists resource', async () => {
|
|
115
|
-
const pfs = new PoweredFileSystem();
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
pfs.chmod('./non-existent-source', 0o744, {
|
|
119
|
-
sync: true
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
catch (err) {
|
|
123
|
-
assert(err.errno === -2);
|
|
124
|
-
}
|
|
125
75
|
});
|
|
126
76
|
});
|
|
127
77
|
});
|
package/test/chown.spec.ts
CHANGED
|
@@ -1,118 +1,86 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
2
|
-
import
|
|
3
|
-
import mockFs from 'mock-fs';
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import fs from 'node:fs';
|
|
4
3
|
import Chance from 'chance';
|
|
5
|
-
import
|
|
4
|
+
import { expect } from 'expect';
|
|
5
|
+
import { fmock, restore } from './__fmock';
|
|
6
|
+
import { pfs } from '../src';
|
|
6
7
|
|
|
7
8
|
describe('chown(src, uid, gid [, options])', () => {
|
|
8
|
-
|
|
9
|
-
const chance = new Chance();
|
|
9
|
+
const chance = new Chance();
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
fmock({
|
|
13
|
+
'./tmpdir/tings.txt': {
|
|
14
|
+
type: 'file',
|
|
15
|
+
data: chance.string()
|
|
15
16
|
},
|
|
16
|
-
'
|
|
17
|
-
path: 'tmpdir/binapp'
|
|
18
|
-
})
|
|
17
|
+
'./tmpdir/digest/': { type: 'directory' }
|
|
19
18
|
});
|
|
20
19
|
});
|
|
21
|
-
|
|
22
|
-
afterEach(
|
|
23
|
-
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
restore('./tmpdir');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
|
|
24
26
|
it('Positive: Changes the permissions of a file', async () => {
|
|
25
|
-
const
|
|
27
|
+
const { uid, gid } = fs.statSync('./tmpdir/tings.txt');
|
|
28
|
+
await pfs.chown('./tmpdir/tings.txt', uid, gid);
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
const { uid, gid } = await pfs.stat('./tmpdir');
|
|
29
|
-
|
|
30
|
-
assert(uid === 0 && gid === 0);
|
|
30
|
+
assert(uid && gid);
|
|
31
31
|
});
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
|
|
33
34
|
it('Positive: Changes the permissions of a directory', async () => {
|
|
34
|
-
const
|
|
35
|
+
const { uid, gid } = fs.statSync('./tmpdir/digest');
|
|
36
|
+
await pfs.chown('./tmpdir/digest', uid, gid);
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
const { uid, gid } = await pfs.stat('./tmpdir/libxbase');
|
|
38
|
-
|
|
39
|
-
assert(uid === 0 && gid === 0);
|
|
38
|
+
assert(uid && gid);
|
|
40
39
|
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const pfs = new PoweredFileSystem();
|
|
44
|
-
|
|
45
|
-
const cwd = process.cwd();
|
|
46
|
-
await pfs.chown(`${cwd}${sep}tmpdir${sep}binapp`, 1, 1, {
|
|
47
|
-
resolve: false
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const { uid, gid } = await pfs.stat('./tmpdir/binapp');
|
|
51
|
-
|
|
52
|
-
assert(uid === 1 && gid === 1);
|
|
53
|
-
});
|
|
54
|
-
|
|
40
|
+
|
|
41
|
+
|
|
55
42
|
it('Negative: To a non-existent resource to return an Error', async () => {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
43
|
+
const guid = chance.guid();
|
|
44
|
+
const { uid, gid } = fs.statSync('./tmpdir/tings.txt');
|
|
45
|
+
|
|
46
|
+
await expect(async () => {
|
|
47
|
+
await pfs.chown(`./tmpdir/${guid}`, uid, gid);
|
|
48
|
+
})
|
|
49
|
+
.rejects
|
|
50
|
+
.toThrow();
|
|
64
51
|
});
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
it('[sync] Positive: Changes the permissions of a file', () => {
|
|
55
|
+
const { uid, gid } = fs.statSync('./tmpdir/tings.txt');
|
|
65
56
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const pfs = new PoweredFileSystem();
|
|
69
|
-
|
|
70
|
-
pfs.chown('./tmpdir/binapp', 1, 1, {
|
|
71
|
-
sync: true
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const { uid, gid } = await pfs.stat('./tmpdir/binapp');
|
|
75
|
-
|
|
76
|
-
assert(uid === 1 && gid === 1);
|
|
57
|
+
pfs.chown('./tmpdir/tings.txt', uid, gid, {
|
|
58
|
+
sync: true
|
|
77
59
|
});
|
|
78
60
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const { uid, gid } = await pfs.stat('./tmpdir');
|
|
61
|
+
assert(uid && gid);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
it('[sync] Positive: Changes the permissions of a directory', () => {
|
|
66
|
+
const { uid, gid } = fs.statSync('./tmpdir/digest');
|
|
87
67
|
|
|
88
|
-
|
|
68
|
+
pfs.chown('./tmpdir/digest', uid, gid, {
|
|
69
|
+
sync: true
|
|
89
70
|
});
|
|
90
71
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
72
|
+
assert(uid && gid);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
it('[sync] Negative: To a non-existent resource to return an Error', () => {
|
|
77
|
+
const guid = chance.guid();
|
|
78
|
+
const { uid, gid } = fs.statSync('./tmpdir/tings.txt');
|
|
79
|
+
|
|
80
|
+
assert.throws(() => {
|
|
81
|
+
pfs.chown(`./tmpdir/${guid}`, uid, gid, {
|
|
82
|
+
sync: true
|
|
98
83
|
});
|
|
99
|
-
|
|
100
|
-
const { uid, gid } = await pfs.stat('./tmpdir/binapp');
|
|
101
|
-
|
|
102
|
-
assert(uid === 1 && gid === 1);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it(`Negative: To a non-existent resource to return an Error`, async () => {
|
|
106
|
-
const pfs = new PoweredFileSystem();
|
|
107
|
-
|
|
108
|
-
try {
|
|
109
|
-
pfs.chown('./non-existent-source', 1, 1, {
|
|
110
|
-
sync: true
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
catch (err) {
|
|
114
|
-
assert(err.errno === -2);
|
|
115
|
-
}
|
|
116
84
|
});
|
|
117
85
|
});
|
|
118
86
|
});
|
package/test/constructor.spec.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
2
|
-
import PoweredFileSystem from '../src';
|
|
3
|
-
|
|
4
|
-
describe('#constructor: new PoweredFileSystem(path)', () => {
|
|
5
|
-
it('Positive: Must be backwards compatible with #require', () => {
|
|
6
|
-
assert(require('../src') === PoweredFileSystem);
|
|
7
|
-
});
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { PoweredFileSystem } from '../src';
|
|
8
3
|
|
|
4
|
+
describe('#constructor: new PoweredFileSystem(pwd?)', () => {
|
|
9
5
|
it('Positive: An empty path must match the context of the cwd', () => {
|
|
10
6
|
const { pwd } = new PoweredFileSystem();
|
|
11
7
|
assert(pwd === process.cwd());
|
|
12
8
|
});
|
|
13
9
|
|
|
10
|
+
|
|
14
11
|
it('Positive: Absolute path must match the context of the pwd', () => {
|
|
15
12
|
const { pwd } = new PoweredFileSystem(__dirname);
|
|
16
13
|
assert(pwd === __dirname);
|
package/test/copy.spec.ts
CHANGED
|
@@ -1,171 +1,101 @@
|
|
|
1
|
-
import assert from 'assert';
|
|
2
|
-
import
|
|
3
|
-
import { sep } from 'path';
|
|
4
|
-
import mockFs from 'mock-fs';
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import fs from 'node:fs';
|
|
5
3
|
import Chance from 'chance';
|
|
6
|
-
import
|
|
4
|
+
import { expect } from 'expect';
|
|
5
|
+
import { fmock, restore } from './__fmock';
|
|
6
|
+
import { pfs } from '../src';
|
|
7
7
|
|
|
8
8
|
describe('copy(src, dir [, options])', () => {
|
|
9
|
+
const chance = new Chance();
|
|
10
|
+
|
|
9
11
|
beforeEach(() => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
'binapp': chance.string(),
|
|
15
|
-
'libxbase': mockFs.directory()
|
|
12
|
+
fmock({
|
|
13
|
+
'./tmpdir/tings.txt': {
|
|
14
|
+
type: 'file',
|
|
15
|
+
data: chance.string()
|
|
16
16
|
},
|
|
17
|
-
'
|
|
18
|
-
path: 'tmpdir/binapp'
|
|
19
|
-
})
|
|
17
|
+
'./tmpdir/digest/': { type: 'directory' }
|
|
20
18
|
});
|
|
21
19
|
});
|
|
22
|
-
|
|
23
|
-
afterEach(
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
restore('./tmpdir');
|
|
23
|
+
});
|
|
24
24
|
|
|
25
25
|
it('Positive: Copying a item file', async () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const { mode } = await pfs.stat(`${dist}/binapp`);
|
|
32
|
-
const umask = PoweredFileSystem.bitmask(mode);
|
|
33
|
-
|
|
34
|
-
assert(umask === 0o666);
|
|
26
|
+
await pfs.copy('./tmpdir/tings.txt', './tmpdir/digest');
|
|
27
|
+
const exist = fs.existsSync(`./tmpdir/digest/tings.txt`);
|
|
28
|
+
|
|
29
|
+
assert(exist);
|
|
35
30
|
});
|
|
31
|
+
|
|
36
32
|
|
|
37
33
|
it('Positive: Recursive copying a directory', async () => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const { mode } = await pfs.stat(`${dist}/tmpdir/libxbase`);
|
|
44
|
-
const umask = PoweredFileSystem.bitmask(mode);
|
|
45
|
-
|
|
46
|
-
assert(umask === 0o777);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('Positive: Recursive copying a directory. Permission check of file', async () => {
|
|
50
|
-
const pfs = new PoweredFileSystem();
|
|
51
|
-
|
|
52
|
-
const dist = os.tmpdir();
|
|
53
|
-
await pfs.copy('./tmpdir', dist);
|
|
54
|
-
|
|
55
|
-
const { mode } = await pfs.stat(`${dist}/tmpdir/binapp`);
|
|
56
|
-
const umask = PoweredFileSystem.bitmask(mode);
|
|
57
|
-
|
|
58
|
-
assert(umask === 0o666);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('Positive: Copying a item file when path is absolute', async () => {
|
|
62
|
-
const pfs = new PoweredFileSystem();
|
|
63
|
-
|
|
64
|
-
const cwd = process.cwd();
|
|
65
|
-
const dist = os.tmpdir();
|
|
66
|
-
|
|
67
|
-
await pfs.copy(`${cwd}${sep}tmpdir`, dist, {
|
|
68
|
-
resolve: false
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const { mode } = await pfs.stat(`${dist}/tmpdir/binapp`);
|
|
72
|
-
const umask = PoweredFileSystem.bitmask(mode);
|
|
73
|
-
|
|
74
|
-
assert(umask === 0o666);
|
|
34
|
+
await pfs.copy('./src', './tmpdir');
|
|
35
|
+
const exist = fs.existsSync(`./tmpdir/src`);
|
|
36
|
+
|
|
37
|
+
assert(exist);
|
|
75
38
|
});
|
|
76
39
|
|
|
40
|
+
|
|
77
41
|
it('Negative: Throw if not exists resource', async () => {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
await pfs.copy(
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
42
|
+
const guid = chance.guid();
|
|
43
|
+
|
|
44
|
+
await expect(async () => {
|
|
45
|
+
await pfs.copy(`./${guid}`, '.');
|
|
46
|
+
})
|
|
47
|
+
.rejects
|
|
48
|
+
.toThrow();
|
|
86
49
|
});
|
|
87
|
-
|
|
50
|
+
|
|
51
|
+
|
|
88
52
|
it('Negative: An attempt to copy to an existing resource should return an Error', async () => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
try {
|
|
53
|
+
await expect(async () => {
|
|
92
54
|
await pfs.copy('./tmpdir', '.');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
55
|
+
})
|
|
56
|
+
.rejects
|
|
57
|
+
.toThrow();
|
|
97
58
|
});
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
it('[sync] Positive: Copying a file', () => {
|
|
62
|
+
pfs.copy('./tmpdir/tings.txt', './tmpdir/digest', {
|
|
63
|
+
sync: true
|
|
64
|
+
});
|
|
98
65
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const { mode } = await pfs.stat(`${dist}/binapp`);
|
|
109
|
-
const umask = PoweredFileSystem.bitmask(mode);
|
|
110
|
-
|
|
111
|
-
assert(umask === 0o666);
|
|
66
|
+
const exist = fs.existsSync(`./tmpdir/digest/tings.txt`);
|
|
67
|
+
|
|
68
|
+
assert(exist);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
it('[sync] Positive: Recursive copying a directory', () => {
|
|
73
|
+
pfs.copy('./src', './tmpdir', {
|
|
74
|
+
sync: true
|
|
112
75
|
});
|
|
113
76
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
77
|
+
const exist = fs.existsSync(`./tmpdir/src`);
|
|
78
|
+
|
|
79
|
+
assert(exist);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
it('[sync] Negative: Throw if not exists resource', () => {
|
|
84
|
+
const guid = chance.guid();
|
|
117
85
|
|
|
118
|
-
|
|
86
|
+
assert.throws(() => {
|
|
87
|
+
pfs.copy(`./${guid}`, '.', {
|
|
119
88
|
sync: true
|
|
120
89
|
});
|
|
121
|
-
|
|
122
|
-
const { mode } = await pfs.stat(`${dist}/tmpdir/libxbase`);
|
|
123
|
-
const umask = PoweredFileSystem.bitmask(mode);
|
|
124
|
-
|
|
125
|
-
assert(umask === 0o777);
|
|
126
90
|
});
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
pfs.copy(`${cwd}${sep}tmpdir`, dist, {
|
|
135
|
-
sync: true,
|
|
136
|
-
resolve: false
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
it('[sync] Negative: An attempt to copy to an existing resource should return an Error', () => {
|
|
95
|
+
assert.throws(() => {
|
|
96
|
+
pfs.copy('./tmpdir', '.', {
|
|
97
|
+
sync: true
|
|
137
98
|
});
|
|
138
|
-
|
|
139
|
-
const { mode } = await pfs.stat(`${dist}/tmpdir/binapp`);
|
|
140
|
-
const umask = PoweredFileSystem.bitmask(mode);
|
|
141
|
-
|
|
142
|
-
assert(umask === 0o666);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('Negative: Throw if not exists resource', async () => {
|
|
146
|
-
const pfs = new PoweredFileSystem();
|
|
147
|
-
|
|
148
|
-
try {
|
|
149
|
-
pfs.copy('./non-existent', '.', {
|
|
150
|
-
sync: true
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
catch (err) {
|
|
154
|
-
assert(err.errno === -2);
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('Negative: An attempt to copy to an existing resource should return an Error', async () => {
|
|
159
|
-
const pfs = new PoweredFileSystem();
|
|
160
|
-
|
|
161
|
-
try {
|
|
162
|
-
pfs.copy('./tmpdir', '.', {
|
|
163
|
-
sync: true
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
catch (err) {
|
|
167
|
-
assert(err.errno === -17);
|
|
168
|
-
}
|
|
169
99
|
});
|
|
170
100
|
});
|
|
171
|
-
});
|
|
101
|
+
});
|