pwd-fs 2.4.1 → 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 +2 -15
  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
package/test/read.spec.ts DELETED
@@ -1,130 +0,0 @@
1
- import assert from 'assert';
2
- import { sep } from 'path';
3
- import mockFs from 'mock-fs';
4
- import Chance from 'chance';
5
- import PoweredFileSystem from '../src';
6
-
7
- describe('read(src [, options])', () => {
8
- beforeEach(() => {
9
- const chance = new Chance();
10
-
11
- mockFs({
12
- 'tmpdir': {
13
- 'binapp': chance.string(),
14
- 'libxbase': mockFs.directory()
15
- },
16
- 'flexapp': mockFs.symlink({
17
- path: 'tmpdir/binapp'
18
- })
19
- });
20
- });
21
-
22
- afterEach(mockFs.restore);
23
-
24
- it('Positive: Must read content of file; String type by default', async () => {
25
- const pfs = new PoweredFileSystem();
26
-
27
- const raw = await pfs.read('./tmpdir/binapp');
28
-
29
- assert(raw.length > 0);
30
- });
31
-
32
- it('Positive: Must read Buffer content of file when encoding is null', async () => {
33
- const pfs = new PoweredFileSystem();
34
-
35
- const raw = await pfs.read('./tmpdir/binapp', {
36
- encoding: null
37
- });
38
-
39
- assert(raw instanceof Buffer);
40
- });
41
-
42
- it('Positive: Must read content of file, when path is absolute', async () => {
43
- const pfs = new PoweredFileSystem();
44
-
45
- const cwd = process.cwd();
46
-
47
- const raw = await pfs.read(`${cwd}${sep}tmpdir${sep}binapp`, {
48
- resolve: false
49
- });
50
-
51
- assert(raw.length > 0);
52
- });
53
-
54
- it('Negative: Throw if resource is not file', async () => {
55
- const pfs = new PoweredFileSystem();
56
-
57
- try {
58
- await pfs.read(`./tmpdir/libxbase`);
59
- }
60
- catch (err) {
61
- assert(err.errno === -21);
62
- }
63
- });
64
-
65
- it('Negative: Throw if not exists resource', async () => {
66
- const pfs = new PoweredFileSystem();
67
- const chance = new Chance();
68
-
69
- const base = chance.guid();
70
-
71
- try {
72
- await pfs.read(`./${base}`);
73
- }
74
- catch (err) {
75
- assert(err.errno === -2);
76
- }
77
- });
78
-
79
- describe('sync mode', () => {
80
- it('Positive: Must read content of file; String type by default', async () => {
81
- const pfs = new PoweredFileSystem();
82
-
83
- const { length } = pfs.read('./tmpdir/binapp', {
84
- sync: true
85
- });
86
-
87
- assert(length > 0);
88
- });
89
-
90
- it('Positive: Must read Buffer content of file when encoding is null', async () => {
91
- const pfs = new PoweredFileSystem();
92
-
93
- const raw = pfs.read('./tmpdir/binapp', {
94
- encoding: null,
95
- sync: true
96
- });
97
-
98
- assert(raw instanceof Buffer);
99
- });
100
-
101
- it('Positive: Must read content of file, when path is absolute', async () => {
102
- const pfs = new PoweredFileSystem();
103
-
104
- const cwd = process.cwd();
105
-
106
- const { length } = pfs.read(`${cwd}${sep}tmpdir${sep}binapp`, {
107
- sync: true,
108
- resolve: false
109
- });
110
-
111
- assert(length > 0);
112
- });
113
-
114
- it(`Negative: Throw if not exists resource`, async () => {
115
- const pfs = new PoweredFileSystem();
116
- const chance = new Chance();
117
-
118
- const base = chance.guid();
119
-
120
- try {
121
- pfs.read(`./${base}`, {
122
- sync: true
123
- });
124
- }
125
- catch (err) {
126
- assert(err.errno === -2);
127
- }
128
- });
129
- });
130
- });
@@ -1,134 +0,0 @@
1
- import assert from 'assert';
2
- import { sep } from 'path';
3
- import mockFs from 'mock-fs';
4
- import Chance from 'chance';
5
- import PoweredFileSystem from '../src';
6
-
7
- describe('readdir(src[, options])', () => {
8
- beforeEach(() => {
9
- const chance = new Chance();
10
-
11
- mockFs({
12
- 'tmpdir': {
13
- 'binapp': chance.string(),
14
- 'libxbase': mockFs.directory()
15
- },
16
- 'flexapp': mockFs.symlink({
17
- path: 'tmpdir/binapp'
18
- })
19
- });
20
- });
21
-
22
- afterEach(mockFs.restore);
23
-
24
- it('Positive: Must return a directory listing', async () => {
25
- const pfs = new PoweredFileSystem();
26
-
27
- const listOfFiles = await pfs.readdir('./tmpdir');
28
-
29
- assert.deepStrictEqual(listOfFiles, [
30
- 'binapp',
31
- 'libxbase'
32
- ]);
33
- });
34
-
35
- it('Positive: Must return a directory listing, when path is absolute', async () => {
36
- const pfs = new PoweredFileSystem();
37
-
38
- const cwd = process.cwd();
39
-
40
- const listOfFiles = await pfs.readdir(`${cwd}${sep}tmpdir`, {
41
- resolve: false
42
- });
43
-
44
- assert.deepStrictEqual(listOfFiles, [
45
- 'binapp',
46
- 'libxbase'
47
- ]);
48
- });
49
-
50
- it('Negative: Throw if resource is not directory', async () => {
51
- const pfs = new PoweredFileSystem();
52
-
53
- try {
54
- await pfs.readdir(`./tmpdir/binapp`);
55
- }
56
- catch (err) {
57
- assert(err.errno === -20);
58
- }
59
- });
60
-
61
- it('Negative: Throw if not exists resource', async () => {
62
- const pfs = new PoweredFileSystem();
63
- const chance = new Chance();
64
-
65
- const base = chance.guid();
66
-
67
- try {
68
- await pfs.readdir(`./${base}`);
69
- }
70
- catch (err) {
71
- assert(err.errno === -2);
72
- }
73
- });
74
-
75
- describe('sync mode', () => {
76
- it('Positive: Must return a directory listing', async () => {
77
- const pfs = new PoweredFileSystem();
78
-
79
- const listOfFiles = pfs.readdir('./tmpdir', {
80
- sync: true
81
- });
82
-
83
- assert.deepStrictEqual(listOfFiles, [
84
- 'binapp',
85
- 'libxbase'
86
- ]);
87
- });
88
-
89
- it('Positive: Must return a directory listing, when path is absolute', async () => {
90
- const pfs = new PoweredFileSystem();
91
-
92
- const cwd = process.cwd();
93
-
94
- const listOfFiles = pfs.readdir(`${cwd}${sep}tmpdir`, {
95
- sync: true,
96
- resolve: false
97
- });
98
-
99
- assert.deepStrictEqual(listOfFiles, [
100
- 'binapp',
101
- 'libxbase'
102
- ]);
103
- });
104
-
105
- it('Negative: Throw if resource is not directory', async () => {
106
- const pfs = new PoweredFileSystem();
107
-
108
- try {
109
- pfs.readdir(`./tmpdir/binapp`, {
110
- sync: true
111
- });
112
- }
113
- catch (err) {
114
- assert(err.errno === -20);
115
- }
116
- });
117
-
118
- it(`Negative: Throw if not exists resource`, async () => {
119
- const pfs = new PoweredFileSystem();
120
- const chance = new Chance();
121
-
122
- const base = chance.guid();
123
-
124
- try {
125
- pfs.readdir(`./${base}`, {
126
- sync: true
127
- });
128
- }
129
- catch (err) {
130
- assert(err.errno === -2);
131
- }
132
- });
133
- });
134
- });
@@ -1,102 +0,0 @@
1
- import assert from 'assert';
2
- import { sep } from 'path';
3
- import mockFs from 'mock-fs';
4
- import Chance from 'chance';
5
- import PoweredFileSystem from '../src';
6
-
7
- describe('remove(src [, options])', () => {
8
- beforeEach(() => {
9
- const chance = new Chance();
10
-
11
- mockFs({
12
- 'tmpdir': {
13
- 'binapp': chance.string(),
14
- 'libxbase': mockFs.directory()
15
- },
16
- 'flexapp': mockFs.symlink({
17
- path: 'tmpdir/binapp'
18
- })
19
- });
20
- });
21
-
22
- afterEach(mockFs.restore);
23
-
24
- it('Positive: Removal a directory with a file', async () => {
25
- const pfs = new PoweredFileSystem();
26
-
27
- await pfs.remove('./tmpdir');
28
-
29
- const exist = await pfs.test('./tmpdir');
30
- assert(exist === false);
31
- });
32
-
33
- it('Positive: Removal a directory with a file, when path is absolute', async () => {
34
- const pfs = new PoweredFileSystem();
35
-
36
- const cwd = process.cwd();
37
-
38
- await pfs.remove(`${cwd}${sep}tmpdir`, {
39
- resolve: false
40
- });
41
-
42
- const exist = await pfs.test('./tmpdir');
43
- assert(exist === false);
44
- });
45
-
46
- it('Negative: Throw if not exists resource', async () => {
47
- const pfs = new PoweredFileSystem();
48
- const chance = new Chance();
49
-
50
- const base = chance.guid();
51
-
52
- try {
53
- await pfs.remove(`./${base}`);
54
- }
55
- catch (err) {
56
- assert(err.errno === -2);
57
- }
58
- });
59
-
60
- describe('sync mode', () => {
61
- it('Positive: Removal a directory with a file', async () => {
62
- const pfs = new PoweredFileSystem();
63
-
64
- pfs.remove('./tmpdir', {
65
- sync: true
66
- });
67
-
68
- const exist = await pfs.test('./tmpdir');
69
- assert(exist === false);
70
- });
71
-
72
- it('Positive: Removal a directory with a file, when path is absolute', async () => {
73
- const pfs = new PoweredFileSystem();
74
-
75
- const cwd = process.cwd();
76
-
77
- pfs.remove(`${cwd}${sep}tmpdir`, {
78
- sync: true,
79
- resolve: false
80
- });
81
-
82
- const exist = await pfs.test('./tmpdir');
83
- assert(exist === false);
84
- });
85
-
86
- it('Negative: Throw if not exists resource', async () => {
87
- const pfs = new PoweredFileSystem();
88
- const chance = new Chance();
89
-
90
- const base = chance.guid();
91
-
92
- try {
93
- pfs.remove(`./${base}`, {
94
- sync: true
95
- });
96
- }
97
- catch (err) {
98
- assert(err.errno === -2);
99
- }
100
- });
101
- });
102
- });
@@ -1,122 +0,0 @@
1
- import assert from 'assert';
2
- import { sep } from 'path';
3
- import mockFs from 'mock-fs';
4
- import Chance from 'chance';
5
- import PoweredFileSystem from '../src';
6
-
7
- describe('rename(src, use [, options])', () => {
8
- beforeEach(() => {
9
- const chance = new Chance();
10
-
11
- mockFs({
12
- 'tmpdir': {
13
- 'binapp': chance.string(),
14
- 'libxbase': mockFs.directory()
15
- },
16
- 'flexapp': mockFs.symlink({
17
- path: 'tmpdir/binapp'
18
- })
19
- });
20
- });
21
-
22
- afterEach(mockFs.restore);
23
-
24
- it('Positive: Must be recursive rename file', async () => {
25
- const pfs = new PoweredFileSystem();
26
-
27
- await pfs.rename('./tmpdir/binapp', './tmpdir/newapp');
28
- const exist = await pfs.test('./tmpdir/newapp');
29
-
30
- assert(exist);
31
- });
32
-
33
- it('Positive: Must be recursive rename directory', async () => {
34
- const pfs = new PoweredFileSystem();
35
-
36
- await pfs.rename('./tmpdir/libxbase', './tmpdir/newxbase');
37
- const exist = await pfs.test('./tmpdir/newxbase');
38
-
39
- assert(exist);
40
- });
41
-
42
- it('Positive: Must be recursive rename directory, when path is absolute', async () => {
43
- const pfs = new PoweredFileSystem();
44
-
45
- const cwd = process.cwd();
46
-
47
- await pfs.rename(`${cwd}${sep}tmpdir`, `${cwd}${sep}newxbase`, {
48
- resolve: false
49
- });
50
-
51
- const exist = await pfs.test('./newxbase');
52
- assert(exist);
53
- });
54
-
55
- it('Negative: Throw if not exists resource', async () => {
56
- const pfs = new PoweredFileSystem();
57
- const chance = new Chance();
58
-
59
- const base = chance.guid();
60
-
61
- try {
62
- await pfs.rename(`./${base}`, './tmpdir/newapp');
63
- }
64
- catch (err) {
65
- assert(err.errno === -2);
66
- }
67
- });
68
-
69
- describe('sync mode', () => {
70
- it('Positive: Must be recursive rename file', async () => {
71
- const pfs = new PoweredFileSystem();
72
-
73
- pfs.rename('./tmpdir/binapp', './tmpdir/newapp', {
74
- sync: true
75
- });
76
-
77
- const exist = await pfs.test('./tmpdir/newapp');
78
- assert(exist);
79
- });
80
-
81
- it('Positive: Must be recursive rename directory', async () => {
82
- const pfs = new PoweredFileSystem();
83
-
84
- pfs.rename('./tmpdir/libxbase', './tmpdir/newxbase', {
85
- sync: true
86
- });
87
-
88
- const exist = await pfs.test('./tmpdir/newxbase');
89
- assert(exist);
90
- });
91
-
92
- it('Positive: Must be recursive rename directory, when path is absolute', async () => {
93
- const pfs = new PoweredFileSystem();
94
-
95
- const cwd = process.cwd();
96
-
97
- pfs.rename(`${cwd}${sep}tmpdir`, `${cwd}${sep}newxbase`, {
98
- sync: true,
99
- resolve: false
100
- });
101
-
102
- const exist = await pfs.test('./newxbase');
103
- assert(exist);
104
- });
105
-
106
- it('Negative: Throw if not exists resource', async () => {
107
- const pfs = new PoweredFileSystem();
108
- const chance = new Chance();
109
-
110
- const base = chance.guid();
111
-
112
- try {
113
- pfs.rename(`./${base}`, './tmpdir/newapp', {
114
- sync: true
115
- });
116
- }
117
- catch (err) {
118
- assert(err.errno === -2);
119
- }
120
- });
121
- });
122
- });
package/test/stat.spec.ts DELETED
@@ -1,131 +0,0 @@
1
- import assert from 'assert';
2
- import { sep } from 'path';
3
- import mockFs from 'mock-fs';
4
- import Chance from 'chance';
5
- import PoweredFileSystem from '../src';
6
-
7
- describe('stat(src [, options])', () => {
8
- beforeEach(() => {
9
- const chance = new Chance();
10
-
11
- mockFs({
12
- 'tmpdir': {
13
- 'binapp': chance.string(),
14
- 'libxbase': mockFs.directory()
15
- },
16
- 'flexapp': mockFs.symlink({
17
- path: 'tmpdir/binapp'
18
- })
19
- });
20
- });
21
-
22
- afterEach(mockFs.restore);
23
-
24
- it('Positive: Must return information a file', async () => {
25
- const pfs = new PoweredFileSystem();
26
-
27
- const stats = await pfs.stat('./tmpdir/binapp');
28
- assert(stats.isFile());
29
- });
30
-
31
- it('Positive: Must return information a directory', async () => {
32
- const pfs = new PoweredFileSystem();
33
-
34
- const stats = await pfs.stat('./tmpdir/libxbase');
35
- assert(stats.isDirectory());
36
- });
37
-
38
- it('Positive: Must return information a symlink', async () => {
39
- const pfs = new PoweredFileSystem();
40
-
41
- const stats = await pfs.stat('./flexapp');
42
- assert(stats.isSymbolicLink());
43
- });
44
-
45
- it('Positive: Must return stats information, when path is absolute', async () => {
46
- const pfs = new PoweredFileSystem();
47
-
48
- const cwd = process.cwd();
49
-
50
- const stats = await pfs.stat(`${cwd}${sep}tmpdir`, {
51
- resolve: false
52
- });
53
-
54
- assert(stats.isDirectory());
55
- });
56
-
57
- it('Negative: Throw if not exists resource', async () => {
58
- const pfs = new PoweredFileSystem();
59
- const chance = new Chance();
60
-
61
- const base = chance.guid();
62
-
63
- try {
64
- await pfs.stat(`./${base}`);
65
- }
66
- catch (err) {
67
- assert(err.errno === -2);
68
- }
69
- });
70
-
71
- describe('sync mode', () => {
72
- it('Positive: Must return information a file', async () => {
73
- const pfs = new PoweredFileSystem();
74
-
75
- const stats = pfs.stat('./tmpdir/binapp', {
76
- sync: true
77
- });
78
-
79
- assert(stats.isFile());
80
- });
81
-
82
- it('Positive: Must return information a directory in ', async () => {
83
- const pfs = new PoweredFileSystem();
84
-
85
- const stats = pfs.stat('./tmpdir/libxbase', {
86
- sync: true
87
- });
88
-
89
- assert(stats.isDirectory());
90
- });
91
-
92
- it('Positive: Must return information a symlink', async () => {
93
- const pfs = new PoweredFileSystem();
94
-
95
- const stats = pfs.stat('./flexapp', {
96
- sync: true
97
- });
98
-
99
- assert(stats.isSymbolicLink());
100
- });
101
-
102
- it('Positive: Must return stats information, when path is absolute', async () => {
103
- const pfs = new PoweredFileSystem();
104
-
105
- const cwd = process.cwd();
106
-
107
- const stats = pfs.stat(`${cwd}${sep}tmpdir`, {
108
- sync: true,
109
- resolve: false
110
- });
111
-
112
- assert(stats.isDirectory());
113
- });
114
-
115
- it('Negative: Throw if not exists resource', async () => {
116
- const pfs = new PoweredFileSystem();
117
- const chance = new Chance();
118
-
119
- const base = chance.guid();
120
-
121
- try {
122
- pfs.stat(`./${base}`, {
123
- sync: true
124
- });
125
- }
126
- catch (err) {
127
- assert(err.errno === -2);
128
- }
129
- });
130
- });
131
- });