pwd-fs 3.2.4 → 3.3.2
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/bitmask.d.ts +4 -0
- package/dist/bitmask.js +17 -0
- package/dist/bitmask.test.d.ts +1 -0
- package/dist/bitmask.test.js +29 -0
- package/dist/{src/index.d.ts → index.d.ts} +3 -0
- package/dist/{src/index.js → index.js} +3 -0
- package/dist/powered-file-system/append.d.ts +9 -0
- package/dist/powered-file-system/append.js +10 -0
- package/dist/powered-file-system/append.test.d.ts +1 -0
- package/dist/powered-file-system/append.test.js +47 -0
- package/dist/powered-file-system/chmod.d.ts +7 -0
- package/dist/powered-file-system/chmod.js +28 -0
- package/dist/powered-file-system/chmod.test.d.ts +1 -0
- package/dist/powered-file-system/chmod.test.js +71 -0
- package/dist/powered-file-system/chown.d.ts +9 -0
- package/dist/powered-file-system/chown.js +45 -0
- package/dist/powered-file-system/chown.test.d.ts +1 -0
- package/dist/powered-file-system/chown.test.js +82 -0
- package/dist/powered-file-system/copy.d.ts +8 -0
- package/dist/powered-file-system/copy.js +29 -0
- package/dist/powered-file-system/copy.test.d.ts +1 -0
- package/dist/powered-file-system/copy.test.js +82 -0
- package/dist/powered-file-system/mkdir.d.ts +8 -0
- package/dist/powered-file-system/mkdir.js +28 -0
- package/dist/powered-file-system/mkdir.test.d.ts +1 -0
- package/dist/powered-file-system/mkdir.test.js +116 -0
- package/dist/powered-file-system/read.d.ts +9 -0
- package/dist/powered-file-system/read.js +29 -0
- package/dist/powered-file-system/read.test.d.ts +1 -0
- package/dist/powered-file-system/read.test.js +75 -0
- package/dist/powered-file-system/readdir.d.ts +8 -0
- package/dist/powered-file-system/readdir.js +26 -0
- package/dist/powered-file-system/readdir.test.d.ts +1 -0
- package/dist/powered-file-system/readdir.test.js +72 -0
- package/dist/powered-file-system/remove.d.ts +7 -0
- package/dist/powered-file-system/remove.js +36 -0
- package/dist/powered-file-system/remove.test.d.ts +1 -0
- package/dist/powered-file-system/remove.test.js +78 -0
- package/dist/powered-file-system/rename.d.ts +7 -0
- package/dist/powered-file-system/rename.js +28 -0
- package/dist/powered-file-system/rename.test.d.ts +1 -0
- package/dist/powered-file-system/rename.test.js +70 -0
- package/dist/powered-file-system/stat.d.ts +7 -0
- package/dist/powered-file-system/stat.js +26 -0
- package/dist/powered-file-system/stat.test.d.ts +1 -0
- package/dist/powered-file-system/stat.test.js +79 -0
- package/dist/powered-file-system/symlink.d.ts +4 -0
- package/dist/powered-file-system/symlink.js +52 -0
- package/dist/powered-file-system/symlink.test.d.ts +1 -0
- package/dist/powered-file-system/symlink.test.js +77 -0
- package/dist/powered-file-system/test.d.ts +8 -0
- package/dist/powered-file-system/test.js +30 -0
- package/dist/powered-file-system/test.test.d.ts +1 -0
- package/dist/powered-file-system/test.test.js +76 -0
- package/dist/powered-file-system/write.d.ts +10 -0
- package/dist/powered-file-system/write.js +36 -0
- package/dist/powered-file-system/write.test.d.ts +1 -0
- package/dist/powered-file-system/write.test.js +97 -0
- package/dist/powered-file-system.d.ts +127 -0
- package/dist/powered-file-system.js +144 -0
- package/dist/powered-file-system.test.d.ts +1 -0
- package/dist/powered-file-system.test.js +21 -0
- package/dist/recurse-io-sync.d.ts +20 -0
- package/dist/{src/recurse-io-sync.js → recurse-io-sync.js} +37 -37
- package/dist/{src/recurse-io.d.ts → recurse-io.d.ts} +15 -1
- package/dist/{src/recurse-io.js → recurse-io.js} +52 -58
- package/dist/suite.test.d.ts +1 -0
- package/dist/suite.test.js +40 -0
- package/dist/test-utils.d.ts +18 -0
- package/dist/test-utils.js +72 -0
- package/package.json +31 -14
- package/readme.md +331 -246
- package/.travis.yml +0 -12
- package/appveyor.yml +0 -16
- package/dist/src/bitmask.d.ts +0 -1
- package/dist/src/bitmask.js +0 -18
- package/dist/src/powered-file-system.d.ts +0 -173
- package/dist/src/powered-file-system.js +0 -262
- package/dist/src/recurse-io-sync.d.ts +0 -5
- package/src/bitmask.ts +0 -20
- package/src/index.ts +0 -7
- package/src/powered-file-system.ts +0 -508
- package/src/recurse-io-sync.ts +0 -108
- package/src/recurse-io.ts +0 -238
- package/test/__fmock.ts +0 -45
- package/test/append.spec.ts +0 -71
- package/test/bitmask.spec.ts +0 -23
- package/test/chmod.spec.ts +0 -77
- package/test/chown.spec.ts +0 -92
- package/test/constructor.spec.ts +0 -15
- package/test/copy.spec.ts +0 -101
- package/test/mkdir.spec.ts +0 -121
- package/test/read.spec.ts +0 -91
- package/test/readdir.spec.ts +0 -86
- package/test/remove.spec.ts +0 -78
- package/test/rename.spec.ts +0 -84
- package/test/stat.spec.ts +0 -99
- package/test/symlink.spec.ts +0 -95
- package/test/test.spec.ts +0 -80
- package/test/write.spec.ts +0 -104
- package/tsconfig.json +0 -14
package/test/mkdir.spec.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import Chance from 'chance';
|
|
4
|
-
import { expect } from 'expect';
|
|
5
|
-
import { fmock, restore } from './__fmock';
|
|
6
|
-
import { PoweredFileSystem } from '../src';
|
|
7
|
-
|
|
8
|
-
describe('mkdir(src [, options])', () => {
|
|
9
|
-
const pfs = new PoweredFileSystem();
|
|
10
|
-
const chance = new Chance();
|
|
11
|
-
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
fmock({
|
|
14
|
-
'./tmpdir/tings.txt': {
|
|
15
|
-
type: 'file',
|
|
16
|
-
data: chance.string()
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterEach(() => {
|
|
22
|
-
restore('./tmpdir');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('Positive: Create directories in the working directory', async () => {
|
|
26
|
-
const guid = chance.guid();
|
|
27
|
-
|
|
28
|
-
await pfs.mkdir(`./tmpdir/${guid}`);
|
|
29
|
-
const exist = fs.existsSync(`./tmpdir/${guid}`);
|
|
30
|
-
|
|
31
|
-
assert(exist);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
it(`Positive: Make current directory`, async () => {
|
|
36
|
-
const guid = chance.guid();
|
|
37
|
-
const pfs = new PoweredFileSystem(`./tmpdir/${guid}`);
|
|
38
|
-
|
|
39
|
-
await pfs.mkdir('.');
|
|
40
|
-
const exist = fs.existsSync(`./tmpdir/${guid}`);
|
|
41
|
-
|
|
42
|
-
assert(exist);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
it('Positive: Should work fine with the existing directory', async () => {
|
|
47
|
-
const guid = chance.guid();
|
|
48
|
-
|
|
49
|
-
for (let i = 2; i; i--) {
|
|
50
|
-
await pfs.mkdir(`./tmpdir/${guid}`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const exist = fs.existsSync(`./tmpdir/${guid}`);
|
|
54
|
-
|
|
55
|
-
assert(exist);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
it('Negative: Throw an exception if trying to create a directory in file', async () => {
|
|
60
|
-
const guid = chance.guid();
|
|
61
|
-
|
|
62
|
-
await expect(async () => {
|
|
63
|
-
await pfs.mkdir(`./tmpdir/tings.txt/${guid}`);
|
|
64
|
-
})
|
|
65
|
-
.rejects
|
|
66
|
-
.toThrow();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
it('Positive: Create directories in the working directory', () => {
|
|
71
|
-
const guid = chance.guid();
|
|
72
|
-
|
|
73
|
-
pfs.mkdir(`./tmpdir/${guid}`, {
|
|
74
|
-
sync: true
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const exist = fs.existsSync(`./tmpdir/${guid}`);
|
|
78
|
-
|
|
79
|
-
assert(exist);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
it('[sync] Positive: Make current directory', () => {
|
|
84
|
-
const guid = chance.guid();
|
|
85
|
-
const pfs = new PoweredFileSystem(`./tmpdir/${guid}`);
|
|
86
|
-
|
|
87
|
-
pfs.mkdir('.', {
|
|
88
|
-
sync: true
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
const exist = fs.existsSync(`./tmpdir/${guid}`);
|
|
92
|
-
|
|
93
|
-
assert(exist);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
it('[sync] Positive: Should work fine with the existing directory', () => {
|
|
98
|
-
const guid = chance.guid();
|
|
99
|
-
|
|
100
|
-
for (let i = 2; i; i--) {
|
|
101
|
-
pfs.mkdir(`./tmpdir/${guid}`, {
|
|
102
|
-
sync: true
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const exist = fs.existsSync(`./tmpdir/${guid}`);
|
|
107
|
-
|
|
108
|
-
assert(exist);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
it('[sync] Negative: Throw an exception if trying to create a directory in file', () => {
|
|
113
|
-
const guid = chance.guid();
|
|
114
|
-
|
|
115
|
-
assert.throws(() => {
|
|
116
|
-
pfs.mkdir(`./tmpdir/tings.txt/${guid}`, {
|
|
117
|
-
sync: true
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
});
|
package/test/read.spec.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import Chance from 'chance';
|
|
3
|
-
import { expect } from 'expect';
|
|
4
|
-
import { fmock, restore } from './__fmock';
|
|
5
|
-
import { pfs } from '../src';
|
|
6
|
-
|
|
7
|
-
describe('read(src [, options])', () => {
|
|
8
|
-
const chance = new Chance();
|
|
9
|
-
let sentences = 0;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
const tingsContent = chance.paragraph();
|
|
13
|
-
sentences = tingsContent.length;
|
|
14
|
-
|
|
15
|
-
fmock({
|
|
16
|
-
'./tmpdir/tings.txt': {
|
|
17
|
-
type: 'file',
|
|
18
|
-
data: tingsContent
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
afterEach(() => {
|
|
24
|
-
restore('./tmpdir');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('Positive: Must read content of file; String type by default', async () => {
|
|
28
|
-
const { length } = await pfs.read('./tmpdir/tings.txt');
|
|
29
|
-
|
|
30
|
-
assert(length === sentences);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
it('Positive: Must read Buffer content of file when encoding is null', async () => {
|
|
35
|
-
const buffer = await pfs.read('./tmpdir/tings.txt', {
|
|
36
|
-
encoding: null
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
assert(buffer instanceof Buffer);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
it('Negative: Throw if resource is not file', async () => {
|
|
44
|
-
await expect(async () => {
|
|
45
|
-
await pfs.read(`./tmpdir`);
|
|
46
|
-
})
|
|
47
|
-
.rejects
|
|
48
|
-
.toThrow();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
it('Negative: Throw if not exists resource', async () => {
|
|
53
|
-
const guid = chance.guid();
|
|
54
|
-
|
|
55
|
-
await expect(async () => {
|
|
56
|
-
await pfs.read(`./tmpdir/${guid}`);
|
|
57
|
-
})
|
|
58
|
-
.rejects
|
|
59
|
-
.toThrow();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
it('[sync] Positive: Must read content of file; String type by default', () => {
|
|
64
|
-
const { length } = pfs.read('./tmpdir/tings.txt', {
|
|
65
|
-
sync: true
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
assert(length === sentences);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
it('[sync] Positive: Must read Buffer content of file when encoding is null', () => {
|
|
73
|
-
const buf = pfs.read('./tmpdir/tings.txt', {
|
|
74
|
-
sync: true,
|
|
75
|
-
encoding: null
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
assert(buf instanceof Buffer);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
it(`[sync] Negative: Throw if not exists resource`, () => {
|
|
83
|
-
const guid = chance.guid();
|
|
84
|
-
|
|
85
|
-
assert.throws(() => {
|
|
86
|
-
pfs.read(`./tmpdir/${guid}`, {
|
|
87
|
-
sync: true
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
});
|
package/test/readdir.spec.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import Chance from 'chance';
|
|
3
|
-
import { expect } from 'expect';
|
|
4
|
-
import { Iframe, fmock, restore } from './__fmock';
|
|
5
|
-
import { pfs } from '../src';
|
|
6
|
-
|
|
7
|
-
describe('readdir(src[, options])', () => {
|
|
8
|
-
const chance = new Chance();
|
|
9
|
-
let counter = 0;
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
const frame: Iframe = {
|
|
13
|
-
'./tmpdir/tings.txt': {
|
|
14
|
-
type: 'file',
|
|
15
|
-
data: chance.string()
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
counter = chance.natural({ max: 7 });
|
|
20
|
-
|
|
21
|
-
for (let i = 0; i < counter; i++) {
|
|
22
|
-
frame[`./tmpdir/${i}`] = { type: 'directory' };
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
fmock(frame);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
restore('./tmpdir');
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('Positive: Must return a directory listing', async () => {
|
|
33
|
-
const { length } = await pfs.readdir('./tmpdir');
|
|
34
|
-
|
|
35
|
-
assert(counter + 1 === length);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
it('Negative: Throw if resource is not directory', async () => {
|
|
40
|
-
await expect(async () => {
|
|
41
|
-
await pfs.readdir(`./tmpdir/tings.txt`);
|
|
42
|
-
})
|
|
43
|
-
.rejects
|
|
44
|
-
.toThrow();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
it('Negative: Throw if not exists resource', async () => {
|
|
49
|
-
const guid = chance.guid();
|
|
50
|
-
|
|
51
|
-
await expect(async () => {
|
|
52
|
-
await pfs.readdir(`./tmpdir/${guid}`);
|
|
53
|
-
})
|
|
54
|
-
.rejects
|
|
55
|
-
.toThrow();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
it('[sync] Positive: Must return a directory listing', () => {
|
|
60
|
-
const { length } = pfs.readdir('./tmpdir', {
|
|
61
|
-
sync: true
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
assert(counter + 1 === length);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
it('Negative: Throw if resource is not directory', () => {
|
|
69
|
-
assert.throws(() => {
|
|
70
|
-
pfs.readdir(`./tmpdir/tings.txt`, {
|
|
71
|
-
sync: true
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
it(`Negative: Throw if not exists resource`, () => {
|
|
78
|
-
const guid = chance.guid();
|
|
79
|
-
|
|
80
|
-
assert.throws(() => {
|
|
81
|
-
pfs.readdir(`./tmpdir/${guid}`, {
|
|
82
|
-
sync: true
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
});
|
package/test/remove.spec.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import Chance from 'chance';
|
|
4
|
-
import { expect } from 'expect';
|
|
5
|
-
import { Iframe, fmock, restore } from './__fmock';
|
|
6
|
-
import { pfs } from '../src';
|
|
7
|
-
|
|
8
|
-
describe('remove(src [, options])', () => {
|
|
9
|
-
const chance = new Chance();
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
const cwd = process.cwd();
|
|
13
|
-
|
|
14
|
-
const frame: Iframe = {
|
|
15
|
-
'./tmpdir/tings.txt': {
|
|
16
|
-
type: 'file',
|
|
17
|
-
data: chance.string()
|
|
18
|
-
},
|
|
19
|
-
'./tmpdir/flexapp': {
|
|
20
|
-
type: 'symlink',
|
|
21
|
-
target: `${cwd}/tmpdir/tings.txt`
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const counter = chance.natural({ max: 7 });
|
|
26
|
-
|
|
27
|
-
for (let i = 0; i < counter; i++) {
|
|
28
|
-
frame[`./tmpdir/${i}`] = { type: 'directory' };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
fmock(frame);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
afterEach(() => {
|
|
35
|
-
restore('./tmpdir');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
it('Positive: Removal a directory with a file', async () => {
|
|
40
|
-
await pfs.remove('./tmpdir');
|
|
41
|
-
const exist = fs.existsSync(`./tmpdir`);
|
|
42
|
-
|
|
43
|
-
assert(exist === false);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
it('Negative: Throw if not exists resource', async () => {
|
|
48
|
-
const guid = chance.guid();
|
|
49
|
-
|
|
50
|
-
await expect(async () => {
|
|
51
|
-
await pfs.remove(`./${guid}`);
|
|
52
|
-
})
|
|
53
|
-
.rejects
|
|
54
|
-
.toThrow();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
it('[sync] Positive: Removal a directory with a file', () => {
|
|
59
|
-
pfs.remove('./tmpdir', {
|
|
60
|
-
sync: true
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const exist = fs.existsSync(`./tmpdir`);
|
|
64
|
-
|
|
65
|
-
assert(exist === false);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
it('[sync] Negative: Throw if not exists resource', () => {
|
|
70
|
-
const guid = chance.guid();
|
|
71
|
-
|
|
72
|
-
assert.throws(() => {
|
|
73
|
-
pfs.remove(`./tmpdir/${guid}`, {
|
|
74
|
-
sync: true
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|
package/test/rename.spec.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import Chance from 'chance';
|
|
4
|
-
import { expect } from 'expect';
|
|
5
|
-
import { fmock, restore } from './__fmock';
|
|
6
|
-
import {pfs } from '../src';
|
|
7
|
-
|
|
8
|
-
describe('rename(src, use [, options])', () => {
|
|
9
|
-
const chance = new Chance();
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
fmock({
|
|
13
|
-
'./tmpdir/tings.txt': {
|
|
14
|
-
type: 'file',
|
|
15
|
-
data: chance.string()
|
|
16
|
-
},
|
|
17
|
-
'./tmpdir/digest/': { type: 'directory' }
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
afterEach(() => {
|
|
22
|
-
restore('./tmpdir');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
it('Positive: Must be recursive rename file', async () => {
|
|
27
|
-
await pfs.rename('./tmpdir/tings.txt', './tmpdir/newapp.txt');
|
|
28
|
-
const exist = fs.existsSync(`./tmpdir/newapp.txt`);
|
|
29
|
-
|
|
30
|
-
assert(exist);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
it('Positive: Must be recursive rename directory', async () => {
|
|
35
|
-
await pfs.rename('./tmpdir/digest', './tmpdir/newxbase');
|
|
36
|
-
const exist = fs.existsSync(`./tmpdir/newxbase`);
|
|
37
|
-
|
|
38
|
-
assert(exist);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
it('Negative: Throw if not exists resource', async () => {
|
|
43
|
-
const guid = chance.guid();
|
|
44
|
-
|
|
45
|
-
await expect(async () => {
|
|
46
|
-
await pfs.rename(`./tmpdir/${guid}`, './tmpdir/newxbase');
|
|
47
|
-
})
|
|
48
|
-
.rejects
|
|
49
|
-
.toThrow();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
it('[sync] Positive: Must be recursive rename file', () => {
|
|
54
|
-
pfs.rename('./tmpdir/tings.txt', './tmpdir/newapp.txt', {
|
|
55
|
-
sync: true
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const exist = fs.existsSync(`./tmpdir/newapp.txt`);
|
|
59
|
-
|
|
60
|
-
assert(exist);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
it('[sync] Positive: Must be recursive rename directory', () => {
|
|
65
|
-
pfs.rename('./tmpdir/digest', './tmpdir/newxbase', {
|
|
66
|
-
sync: true
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
const exist = fs.existsSync(`./tmpdir/newxbase`);
|
|
70
|
-
|
|
71
|
-
assert(exist);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
it('[sync] Negative: Throw if not exists resource', () => {
|
|
76
|
-
const guid = chance.guid();
|
|
77
|
-
|
|
78
|
-
assert.throws(() => {
|
|
79
|
-
pfs.rename(`./tmpdir/${guid}`, './tmpdir/newxbase', {
|
|
80
|
-
sync: true
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|
package/test/stat.spec.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import Chance from 'chance';
|
|
3
|
-
import { expect } from 'expect';
|
|
4
|
-
import { fmock, restore } from './__fmock';
|
|
5
|
-
import { pfs } from '../src';
|
|
6
|
-
|
|
7
|
-
describe('stat(src [, options])', () => {
|
|
8
|
-
const chance = new Chance();
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
const cwd = process.cwd();
|
|
12
|
-
|
|
13
|
-
fmock({
|
|
14
|
-
'./tmpdir/tings.txt': {
|
|
15
|
-
type: 'file',
|
|
16
|
-
data: chance.string()
|
|
17
|
-
},
|
|
18
|
-
'./tmpdir/digest/': { type: 'directory' },
|
|
19
|
-
'./tmpdir/flexapp': {
|
|
20
|
-
type: 'symlink',
|
|
21
|
-
target: `${cwd}/tmpdir/tings.txt`
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
afterEach(() => {
|
|
27
|
-
restore('./tmpdir');
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
it('Positive: Must return information a file', async () => {
|
|
32
|
-
const stats = await pfs.stat('./tmpdir/tings.txt');
|
|
33
|
-
|
|
34
|
-
assert(stats.isFile());
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
it('Positive: Must return information a directory', async () => {
|
|
39
|
-
const stats = await pfs.stat('./tmpdir/digest');
|
|
40
|
-
|
|
41
|
-
assert(stats.isDirectory());
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
it('Positive: Must return information a symlink', async () => {
|
|
46
|
-
const stats = await pfs.stat('./tmpdir/flexapp');
|
|
47
|
-
|
|
48
|
-
assert(stats.isSymbolicLink());
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
it('Negative: Throw if not exists resource', async () => {
|
|
53
|
-
const guid = chance.guid();
|
|
54
|
-
|
|
55
|
-
await expect(async () => {
|
|
56
|
-
await pfs.stat(`./tmpdir/${guid}`);
|
|
57
|
-
})
|
|
58
|
-
.rejects
|
|
59
|
-
.toThrow();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
it('[sync] Positive: Must return information a file', () => {
|
|
64
|
-
const stats = pfs.stat('./tmpdir/tings.txt', {
|
|
65
|
-
sync: true
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
assert(stats.isFile());
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
it('[sync] Positive: Must return information a directory in ', () => {
|
|
73
|
-
const stats = pfs.stat('./tmpdir/digest', {
|
|
74
|
-
sync: true
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
assert(stats.isDirectory());
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
it('[sync] Positive: Must return information a symlink', () => {
|
|
82
|
-
const stats = pfs.stat('./tmpdir/flexapp', {
|
|
83
|
-
sync: true
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
assert(stats.isSymbolicLink());
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
it('[sync] Negative: Throw if not exists resource', () => {
|
|
91
|
-
const guid = chance.guid();
|
|
92
|
-
|
|
93
|
-
assert.throws(() => {
|
|
94
|
-
pfs.stat(`./tmpdir/${guid}`, {
|
|
95
|
-
sync: true
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
});
|
package/test/symlink.spec.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import Chance from 'chance';
|
|
4
|
-
import { expect } from 'expect';
|
|
5
|
-
import { Iframe, fmock, restore } from './__fmock';
|
|
6
|
-
import { pfs } from '../src';
|
|
7
|
-
|
|
8
|
-
describe('symlink(src, use [, options])', () => {
|
|
9
|
-
const chance = new Chance();
|
|
10
|
-
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
const cwd = process.cwd();
|
|
13
|
-
|
|
14
|
-
const frame: Iframe = {
|
|
15
|
-
'./tmpdir/tings.txt': {
|
|
16
|
-
type: 'file',
|
|
17
|
-
data: chance.string()
|
|
18
|
-
},
|
|
19
|
-
'./tmpdir/digest/': { type: 'directory' },
|
|
20
|
-
'./tmpdir/flexapp': {
|
|
21
|
-
type: 'symlink',
|
|
22
|
-
target: `${cwd}/tmpdir/tings.txt`
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const counter = chance.natural({ max: 7 });
|
|
27
|
-
|
|
28
|
-
for (let i = 0; i < counter; i++) {
|
|
29
|
-
frame[`./tmpdir/${i}`] = { type: 'directory' };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
fmock(frame);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
afterEach(() => {
|
|
36
|
-
restore('./tmpdir');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
it('Positive: Must be created a symbolic link', async () => {
|
|
41
|
-
await pfs.symlink('./tmpdir/tings.txt', './tmpdir/linkapp');
|
|
42
|
-
|
|
43
|
-
const stat = fs.lstatSync('./tmpdir/linkapp');
|
|
44
|
-
|
|
45
|
-
assert(stat.isSymbolicLink());
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
it('Positive: Must be created a symbolic link for directory', async () => {
|
|
50
|
-
await pfs.symlink('./tmpdir/digest', './tmpdir/linkapp');
|
|
51
|
-
|
|
52
|
-
const stat = fs.lstatSync('./tmpdir/linkapp');
|
|
53
|
-
|
|
54
|
-
assert(stat.isSymbolicLink());
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
it('Negative: Throw if destination already exists', async () => {
|
|
59
|
-
await expect(async () => {
|
|
60
|
-
await pfs.symlink('./tmpdir/tings.txt', './tmpdir/flexapp');
|
|
61
|
-
})
|
|
62
|
-
.rejects
|
|
63
|
-
.toThrow();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
it('[sync] Positive: Must be created a symbolic link', () => {
|
|
68
|
-
pfs.symlink('./tmpdir/tings.txt', './tmpdir/linkapp', {
|
|
69
|
-
sync: true
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const stat = fs.lstatSync('./tmpdir/linkapp');
|
|
73
|
-
|
|
74
|
-
assert(stat.isSymbolicLink());
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
it('[sync] Positive: Must be created a symbolic link for directory', () => {
|
|
79
|
-
pfs.symlink('./tmpdir/digest', './tmpdir/linkapp', {
|
|
80
|
-
sync: true
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const stat = fs.lstatSync('./tmpdir/linkapp');
|
|
84
|
-
|
|
85
|
-
assert(stat.isSymbolicLink());
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('[sync] Negative: Throw if destination already exists', () => {
|
|
89
|
-
assert.throws(() => {
|
|
90
|
-
pfs.symlink('./tmpdir/tings.txt', './tmpdir/flexapp', {
|
|
91
|
-
sync: true
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
});
|