pwd-fs 2.4.2 → 3.1.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.
Files changed (101) hide show
  1. package/.travis.yml +2 -3
  2. package/__tests__/__fmock.ts +45 -0
  3. package/__tests__/append.spec.ts +72 -0
  4. package/__tests__/bitmask.spec.ts +23 -0
  5. package/__tests__/chmod.spec.ts +78 -0
  6. package/__tests__/chown.spec.ts +88 -0
  7. package/{test → __tests__}/constructor.spec.ts +3 -6
  8. package/__tests__/copy.spec.ts +102 -0
  9. package/__tests__/mkdir.spec.ts +120 -0
  10. package/__tests__/read.spec.ts +92 -0
  11. package/__tests__/readdir.spec.ts +87 -0
  12. package/__tests__/remove.spec.ts +78 -0
  13. package/__tests__/rename.spec.ts +84 -0
  14. package/__tests__/stat.spec.ts +100 -0
  15. package/__tests__/symlink.spec.ts +95 -0
  16. package/__tests__/test.spec.ts +82 -0
  17. package/__tests__/write.spec.ts +104 -0
  18. package/appveyor.yml +2 -4
  19. package/jest.config.ts +14 -0
  20. package/lib/__tests__/__fmock.d.ts +5 -0
  21. package/lib/index.js +24 -0
  22. package/lib/powered-file-system.js +260 -0
  23. package/lib/recurse-io-sync.js +90 -0
  24. package/lib/recurse-io.js +194 -0
  25. package/lib/src/index.d.ts +6 -186
  26. package/lib/src/powered-file-system.d.ts +155 -0
  27. package/lib/src/recurse-io-sync.d.ts +10 -5
  28. package/lib/src/recurse-io.d.ts +14 -6
  29. package/package.json +18 -14
  30. package/readme.md +0 -13
  31. package/rollup.config.js +16 -0
  32. package/src/index.ts +29 -626
  33. package/src/powered-file-system.ts +525 -0
  34. package/src/recurse-io-sync.ts +77 -71
  35. package/src/recurse-io.ts +181 -176
  36. package/tsconfig.json +12 -5
  37. package/lib/src/index.js +0 -297
  38. package/lib/src/index.js.map +0 -1
  39. package/lib/src/recurse-io-sync.js +0 -83
  40. package/lib/src/recurse-io-sync.js.map +0 -1
  41. package/lib/src/recurse-io.js +0 -188
  42. package/lib/src/recurse-io.js.map +0 -1
  43. package/lib/test/append.spec.js +0 -99
  44. package/lib/test/append.spec.js.map +0 -1
  45. package/lib/test/bitmask.spec.js +0 -29
  46. package/lib/test/bitmask.spec.js.map +0 -1
  47. package/lib/test/chmod.spec.js +0 -104
  48. package/lib/test/chmod.spec.js.map +0 -1
  49. package/lib/test/chown.spec.js +0 -94
  50. package/lib/test/chown.spec.js.map +0 -1
  51. package/lib/test/constructor.spec.js +0 -20
  52. package/lib/test/constructor.spec.js.map +0 -1
  53. package/lib/test/copy.spec.js +0 -135
  54. package/lib/test/copy.spec.js.map +0 -1
  55. package/lib/test/mkdir.spec.js +0 -147
  56. package/lib/test/mkdir.spec.js.map +0 -1
  57. package/lib/test/read.spec.js +0 -104
  58. package/lib/test/read.spec.js.map +0 -1
  59. package/lib/test/readdir.spec.js +0 -112
  60. package/lib/test/readdir.spec.js.map +0 -1
  61. package/lib/test/remove.spec.js +0 -84
  62. package/lib/test/remove.spec.js.map +0 -1
  63. package/lib/test/rename.spec.js +0 -98
  64. package/lib/test/rename.spec.js.map +0 -1
  65. package/lib/test/stat.spec.js +0 -104
  66. package/lib/test/stat.spec.js.map +0 -1
  67. package/lib/test/symlink.spec.js +0 -118
  68. package/lib/test/symlink.spec.js.map +0 -1
  69. package/lib/test/test.spec.js +0 -89
  70. package/lib/test/test.spec.js.map +0 -1
  71. package/lib/test/write.spec.js +0 -133
  72. package/lib/test/write.spec.js.map +0 -1
  73. package/test/append.spec.ts +0 -125
  74. package/test/bitmask.spec.ts +0 -26
  75. package/test/chmod.spec.ts +0 -127
  76. package/test/chown.spec.ts +0 -118
  77. package/test/copy.spec.ts +0 -171
  78. package/test/mkdir.spec.ts +0 -187
  79. package/test/read.spec.ts +0 -130
  80. package/test/readdir.spec.ts +0 -134
  81. package/test/remove.spec.ts +0 -102
  82. package/test/rename.spec.ts +0 -122
  83. package/test/stat.spec.ts +0 -131
  84. package/test/symlink.spec.ts +0 -146
  85. package/test/test.spec.ts +0 -113
  86. package/test/write.spec.ts +0 -167
  87. /package/lib/{test → __tests__}/append.spec.d.ts +0 -0
  88. /package/lib/{test → __tests__}/bitmask.spec.d.ts +0 -0
  89. /package/lib/{test → __tests__}/chmod.spec.d.ts +0 -0
  90. /package/lib/{test → __tests__}/chown.spec.d.ts +0 -0
  91. /package/lib/{test → __tests__}/constructor.spec.d.ts +0 -0
  92. /package/lib/{test → __tests__}/copy.spec.d.ts +0 -0
  93. /package/lib/{test → __tests__}/mkdir.spec.d.ts +0 -0
  94. /package/lib/{test → __tests__}/read.spec.d.ts +0 -0
  95. /package/lib/{test → __tests__}/readdir.spec.d.ts +0 -0
  96. /package/lib/{test → __tests__}/remove.spec.d.ts +0 -0
  97. /package/lib/{test → __tests__}/rename.spec.d.ts +0 -0
  98. /package/lib/{test → __tests__}/stat.spec.d.ts +0 -0
  99. /package/lib/{test → __tests__}/symlink.spec.d.ts +0 -0
  100. /package/lib/{test → __tests__}/test.spec.d.ts +0 -0
  101. /package/lib/{test → __tests__}/write.spec.d.ts +0 -0
@@ -0,0 +1,87 @@
1
+ import assert from 'node:assert';
2
+ import fs from 'node:fs';
3
+ import Chance from 'chance';
4
+ import { type Iframe, fmock, restore } from './__fmock';
5
+ import PoweredFileSystem from '../src';
6
+
7
+ describe('readdir(src[, options])', () => {
8
+ const pfs = new PoweredFileSystem();
9
+ const chance = new Chance();
10
+ let counter = 0;
11
+
12
+ beforeEach(() => {
13
+ const frame: Iframe = {
14
+ './tmpdir/tings.txt': {
15
+ type: 'file',
16
+ data: chance.string()
17
+ }
18
+ };
19
+
20
+ counter = chance.natural({ max: 7 });
21
+
22
+ for (let i = 0; i < counter; i++) {
23
+ frame[`./tmpdir/${i}`] = { type: 'directory' };
24
+ }
25
+
26
+ fmock(frame);
27
+ });
28
+
29
+ afterEach(() => {
30
+ restore('./tmpdir');
31
+ });
32
+
33
+ it('Positive: Must return a directory listing', async () => {
34
+ const { length } = await pfs.readdir('./tmpdir');
35
+
36
+ assert(counter + 1 === length);
37
+ });
38
+
39
+
40
+ it('Negative: Throw if resource is not directory', async () => {
41
+ await expect(async () => {
42
+ await pfs.readdir(`./tmpdir/tings.txt`);
43
+ })
44
+ .rejects
45
+ .toThrow();
46
+ });
47
+
48
+
49
+ it('Negative: Throw if not exists resource', async () => {
50
+ const guid = chance.guid();
51
+
52
+ await expect(async () => {
53
+ await pfs.readdir(`./tmpdir/${guid}`);
54
+ })
55
+ .rejects
56
+ .toThrow();
57
+ });
58
+
59
+
60
+ it('[sync] Positive: Must return a directory listing', () => {
61
+ const { length } = pfs.readdir('./tmpdir', {
62
+ sync: true
63
+ });
64
+
65
+ assert(counter + 1 === length);
66
+ });
67
+
68
+
69
+ it('Negative: Throw if resource is not directory', () => {
70
+ assert.throws(() => {
71
+ pfs.readdir(`./tmpdir/tings.txt`, {
72
+ sync: true
73
+ });
74
+ });
75
+ });
76
+
77
+
78
+ it(`Negative: Throw if not exists resource`, () => {
79
+ const guid = chance.guid();
80
+
81
+ assert.throws(() => {
82
+ pfs.readdir(`./tmpdir/${guid}`, {
83
+ sync: true
84
+ });
85
+ });
86
+ });
87
+ });
@@ -0,0 +1,78 @@
1
+ import assert from 'node:assert';
2
+ import fs from 'node:fs';
3
+ import Chance from 'chance';
4
+ import { type Iframe, fmock, restore } from './__fmock';
5
+ import PoweredFileSystem from '../src';
6
+
7
+ describe('remove(src [, options])', () => {
8
+ const pfs = new PoweredFileSystem();
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
+ });
@@ -0,0 +1,84 @@
1
+ import assert from 'node:assert';
2
+ import fs from 'node:fs';
3
+ import Chance from 'chance';
4
+ import { fmock, restore } from './__fmock';
5
+ import PoweredFileSystem from '../src';
6
+
7
+ describe('rename(src, use [, options])', () => {
8
+ const pfs = new PoweredFileSystem();
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
+ });
@@ -0,0 +1,100 @@
1
+ import assert from 'node:assert';
2
+ import fs from 'node:fs';
3
+ import Chance from 'chance';
4
+ import { fmock, restore } from './__fmock';
5
+ import PoweredFileSystem from '../src';
6
+
7
+ describe('stat(src [, options])', () => {
8
+ const pfs = new PoweredFileSystem();
9
+ const chance = new Chance();
10
+
11
+ beforeEach(() => {
12
+ const cwd = process.cwd();
13
+
14
+ fmock({
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
+
27
+ afterEach(() => {
28
+ restore('./tmpdir');
29
+ });
30
+
31
+
32
+ it('Positive: Must return information a file', async () => {
33
+ const stats = await pfs.stat('./tmpdir/tings.txt');
34
+
35
+ assert(stats.isFile());
36
+ });
37
+
38
+
39
+ it('Positive: Must return information a directory', async () => {
40
+ const stats = await pfs.stat('./tmpdir/digest');
41
+
42
+ assert(stats.isDirectory());
43
+ });
44
+
45
+
46
+ it('Positive: Must return information a symlink', async () => {
47
+ const stats = await pfs.stat('./tmpdir/flexapp');
48
+
49
+ assert(stats.isSymbolicLink());
50
+ });
51
+
52
+
53
+ it('Negative: Throw if not exists resource', async () => {
54
+ const guid = chance.guid();
55
+
56
+ await expect(async () => {
57
+ await pfs.stat(`./tmpdir/${guid}`);
58
+ })
59
+ .rejects
60
+ .toThrow();
61
+ });
62
+
63
+
64
+ it('[sync] Positive: Must return information a file', () => {
65
+ const stats = pfs.stat('./tmpdir/tings.txt', {
66
+ sync: true
67
+ });
68
+
69
+ assert(stats.isFile());
70
+ });
71
+
72
+
73
+ it('[sync] Positive: Must return information a directory in ', () => {
74
+ const stats = pfs.stat('./tmpdir/digest', {
75
+ sync: true
76
+ });
77
+
78
+ assert(stats.isDirectory());
79
+ });
80
+
81
+
82
+ it('[sync] Positive: Must return information a symlink', () => {
83
+ const stats = pfs.stat('./tmpdir/flexapp', {
84
+ sync: true
85
+ });
86
+
87
+ assert(stats.isSymbolicLink());
88
+ });
89
+
90
+
91
+ it('[sync] Negative: Throw if not exists resource', () => {
92
+ const guid = chance.guid();
93
+
94
+ assert.throws(() => {
95
+ pfs.stat(`./tmpdir/${guid}`, {
96
+ sync: true
97
+ });
98
+ });
99
+ });
100
+ });
@@ -0,0 +1,95 @@
1
+ import assert from 'node:assert';
2
+ import fs from 'node:fs';
3
+ import Chance from 'chance';
4
+ import { type Iframe, fmock, restore } from './__fmock';
5
+ import PoweredFileSystem from '../src';
6
+
7
+ describe('symlink(src, use [, options])', () => {
8
+ const pfs = new PoweredFileSystem();
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
+ });
@@ -0,0 +1,82 @@
1
+ import assert from 'node:assert';
2
+ import fs from 'node:fs';
3
+ import Chance from 'chance';
4
+ import { fmock, restore } from './__fmock';
5
+ import PoweredFileSystem from '../src';
6
+
7
+ describe('test(src[, options])', () => {
8
+ const pfs = new PoweredFileSystem();
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: Should return 'true' for current working directory`, async () => {
27
+ const exist = await pfs.test('.');
28
+
29
+ assert(exist);
30
+ });
31
+
32
+
33
+ it(`Positive: For existing file should return 'true'`, async () => {
34
+ const exist = await pfs.test('./tmpdir/tings.txt');
35
+
36
+ assert(exist);
37
+ });
38
+
39
+
40
+ it(`Positive: For existing directory should return 'true'`, async () => {
41
+ const exist = await pfs.test('./tmpdir/digest');
42
+
43
+ assert(exist);
44
+ });
45
+
46
+
47
+ it(`Positive: A non-existent file must return 'false'`, async () => {
48
+ const guid = chance.guid();
49
+ const exist = await pfs.test(`./tmpdir/${guid}`);
50
+
51
+ assert(exist === false);
52
+ });
53
+
54
+
55
+ it(`Positive: For existing file should return 'true'`, () => {
56
+ const exist = pfs.test('./tmpdir/tings.txt', {
57
+ sync: true
58
+ });
59
+
60
+ assert(exist);
61
+ });
62
+
63
+
64
+ it(`[sync] Positive: For existing directory should return 'true'`, () => {
65
+ const exist = pfs.test('./tmpdir/digest', {
66
+ sync: true
67
+ });
68
+
69
+ assert(exist);
70
+ });
71
+
72
+
73
+ it(`[sync] Positive: A non-existent file must return 'false'`, () => {
74
+ const guid = chance.guid();
75
+
76
+ const exist = pfs.test(`./tmpdir/${guid}`, {
77
+ sync: true
78
+ });
79
+
80
+ assert(exist === false);
81
+ });
82
+ });
@@ -0,0 +1,104 @@
1
+ import assert from 'node:assert';
2
+ import fs from 'node:fs';
3
+ import Chance from 'chance';
4
+ import { fmock, restore } from './__fmock';
5
+ import PoweredFileSystem from '../src';
6
+
7
+ describe('write(src, data[, options])', () => {
8
+ const pfs = new PoweredFileSystem();
9
+ const chance = new Chance();
10
+
11
+ beforeEach(() => {
12
+ fmock({
13
+ './tmpdir/tings.txt': {
14
+ type: 'file',
15
+ data: chance.string()
16
+ }
17
+ });
18
+ });
19
+
20
+ afterEach(() => {
21
+ restore('./tmpdir');
22
+ });
23
+
24
+ it('Positive: Must write content to file', async () => {
25
+ const payload = chance.paragraph();
26
+ const guid = chance.guid();
27
+
28
+ await pfs.write(`./tmpdir/${guid}.txt`, payload);
29
+ const { size } = fs.lstatSync(`./tmpdir/${guid}.txt`);
30
+
31
+ assert(payload.length === size);
32
+ });
33
+
34
+
35
+ it('Positive: Must rewrite content if file already exists', async () => {
36
+ const payload = chance.paragraph();
37
+
38
+ await pfs.write('./tmpdir/tings.txt', payload);
39
+ const { size } = fs.lstatSync('./tmpdir/tings.txt');
40
+
41
+ assert(payload.length === size);
42
+ });
43
+
44
+
45
+ it('Negative: Throw if resource is directory', async () => {
46
+ const payload = chance.paragraph();
47
+
48
+ await expect(async () => {
49
+ await pfs.write('./tmpdir', payload);
50
+ })
51
+ .rejects
52
+ .toThrow();
53
+ });
54
+
55
+
56
+ it(`Negative: Unexpected option 'flag' returns Error`, async () => {
57
+ const payload = chance.paragraph();
58
+
59
+ await expect(async () => {
60
+ await pfs.write('./tmpdir/tings.txt', payload, {
61
+ flag: 'r'
62
+ });
63
+ })
64
+ .rejects
65
+ .toThrow();
66
+ });
67
+
68
+
69
+ it('[sync] Positive: Write contents even to a non-existent file', () => {
70
+ const payload = chance.paragraph();
71
+ const guid = chance.guid();
72
+
73
+ pfs.write(`./tmpdir/${guid}.txt`, payload, {
74
+ sync: true
75
+ });
76
+
77
+ const content = fs.readFileSync(`./tmpdir/${guid}.txt`, 'utf8');
78
+
79
+ assert(payload === content);
80
+ });
81
+
82
+
83
+ it('[sync] Negative: Throw if resource is directory', () => {
84
+ const payload = chance.paragraph();
85
+
86
+ assert.throws(() => {
87
+ pfs.write('./tmpdir', payload, {
88
+ sync: true
89
+ });
90
+ });
91
+ });
92
+
93
+
94
+ it(`[sync] Negative: Unexpected option 'flag' returns Error`, () => {
95
+ const payload = chance.paragraph();
96
+
97
+ assert.throws(() => {
98
+ pfs.write('./tmpdir/tings.txt', payload, {
99
+ sync: true,
100
+ flag: 'r'
101
+ });
102
+ });
103
+ });
104
+ });
package/appveyor.yml CHANGED
@@ -1,15 +1,13 @@
1
1
  environment:
2
2
  matrix:
3
- - nodejs_version: 8
4
- - nodejs_version: 10
5
- - nodejs_version: 12
6
3
  - nodejs_version: 14
7
4
  - nodejs_version: 16
5
+ - nodejs_version: 18
6
+ - nodejs_version: 20
8
7
  install:
9
8
  - ps: Install-Product node $env:nodejs_version
10
9
  - npm config set loglevel warn
11
10
  - npm install --silent
12
- - npm install -g typescript
13
11
  test_script:
14
12
  - npm run build
15
13
  - npm test
package/jest.config.ts ADDED
@@ -0,0 +1,14 @@
1
+ import type { JestConfigWithTsJest } from 'ts-jest';
2
+
3
+ const config: JestConfigWithTsJest = {
4
+ verbose: true,
5
+ collectCoverage: false,
6
+ errorOnDeprecated: true,
7
+ maxWorkers: 1,
8
+ testMatch: [
9
+ '**/__tests__/**/*.spec.ts'
10
+ ],
11
+ preset: 'ts-jest'
12
+ };
13
+
14
+ export default config;
@@ -0,0 +1,5 @@
1
+ export interface Iframe {
2
+ [key: string]: any;
3
+ }
4
+ export declare function fmock(frame: Iframe): void;
5
+ export declare function restore(tmpDir: string): void;
package/lib/index.js ADDED
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var poweredFileSystem = require('./powered-file-system.js');
6
+
7
+ // const pfs = new PoweredFileSystem();
8
+ // export const test = pfs.test;
9
+ // export const stat = pfs.stat;
10
+ // export const chmod = pfs.chmod;
11
+ // export const chown = pfs.chown;
12
+ // export const symlink = pfs.symlink;
13
+ // export const copy = pfs.copy;
14
+ // export const rename = pfs.rename;
15
+ // export const remove = pfs.remove;
16
+ // export const read = pfs.read;
17
+ // export const write = pfs.write;
18
+ // export const append = pfs.append;
19
+ // export const readdir = pfs.readdir;
20
+ // export const mkdir = pfs.mkdir;
21
+ const bitmask = poweredFileSystem.PoweredFileSystem.bitmask;
22
+
23
+ exports.default = poweredFileSystem.PoweredFileSystem;
24
+ exports.bitmask = bitmask;