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
@@ -1,146 +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('symlink(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 created a symbolic link', async () => {
25
- const pfs = new PoweredFileSystem();
26
-
27
- await pfs.symlink('./tmpdir/binapp', './linkapp');
28
-
29
- const stats = await pfs.stat('./linkapp');
30
- assert(stats.isSymbolicLink());
31
- });
32
-
33
- it('Positive: Must be created a symbolic link for directory', async () => {
34
- const pfs = new PoweredFileSystem();
35
-
36
- await pfs.symlink(`./tmpdir/libxbase`, './linkapp');
37
-
38
- const stats = await pfs.stat('./linkapp');
39
- assert(stats.isSymbolicLink());
40
- });
41
-
42
- it('Positive: Must be created a symbolic, when path is absolute', async () => {
43
- const pfs = new PoweredFileSystem();
44
-
45
- const cwd = process.cwd();
46
-
47
- await pfs.symlink(`${cwd}${sep}tmpdir${sep}libxbase`, `${cwd}${sep}linkapp`, {
48
- resolve: false
49
- });
50
-
51
- const stats = await pfs.stat('./linkapp');
52
- assert(stats.isSymbolicLink());
53
- });
54
-
55
- it('Negative: Throw if destination already exists', async () => {
56
- const pfs = new PoweredFileSystem();
57
-
58
- try {
59
- await pfs.symlink(`./flexapp`, './tmpdir/binapp');
60
- }
61
- catch (err) {
62
- assert(err.errno === -17);
63
- }
64
- });
65
-
66
- it('Negative: Throw if not exists resource', async () => {
67
- const pfs = new PoweredFileSystem();
68
- const chance = new Chance();
69
-
70
- const base = chance.guid();
71
-
72
- try {
73
- await pfs.symlink(`./${base}`, './linkapp');
74
- }
75
- catch (err) {
76
- assert(err.errno === -2);
77
- }
78
- });
79
-
80
- describe('sync mode', () => {
81
- it('Positive: Must be created a symbolic link', async () => {
82
- const pfs = new PoweredFileSystem();
83
-
84
- pfs.symlink('./tmpdir/binapp', './linkapp', {
85
- sync: true
86
- });
87
-
88
- const stats = await pfs.stat('./linkapp');
89
- assert(stats.isSymbolicLink());
90
- });
91
-
92
- it('Positive: Must be created a symbolic link for directory', async () => {
93
- const pfs = new PoweredFileSystem();
94
-
95
- pfs.symlink(`./tmpdir/libxbase`, './linkapp', {
96
- sync: true
97
- });
98
-
99
- const stats = await pfs.stat('./linkapp');
100
- assert(stats.isSymbolicLink());
101
- });
102
-
103
- it('Positive: Must be created a symbolic, when path is absolute', async () => {
104
- const pfs = new PoweredFileSystem();
105
-
106
- const cwd = process.cwd();
107
-
108
- pfs.symlink(`${cwd}${sep}tmpdir${sep}libxbase`, `${cwd}${sep}linkapp`, {
109
- sync: true,
110
- resolve: false
111
- });
112
-
113
- const stats = await pfs.stat('./linkapp');
114
- assert(stats.isSymbolicLink());
115
- });
116
-
117
- it('Negative: Throw if destination already exists', async () => {
118
- const pfs = new PoweredFileSystem();
119
-
120
- try {
121
- pfs.symlink(`./flexapp`, './tmpdir/binapp', {
122
- sync: true
123
- });
124
- }
125
- catch (err) {
126
- assert(err.errno === -17);
127
- }
128
- });
129
-
130
- it('Negative: Throw if not exists resource', async () => {
131
- const pfs = new PoweredFileSystem();
132
- const chance = new Chance();
133
-
134
- const base = chance.guid();
135
-
136
- try {
137
- pfs.symlink(`./${base}`, './linkapp', {
138
- sync: true
139
- });
140
- }
141
- catch (err) {
142
- assert(err.errno === -2);
143
- }
144
- });
145
- });
146
- });
package/test/test.spec.ts DELETED
@@ -1,113 +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('test(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: Should return 'true' for current working directory`, async () => {
25
- const pfs = new PoweredFileSystem();
26
-
27
- const exist = await pfs.test('.');
28
- assert(exist);
29
- });
30
-
31
- it(`Positive: For existing directory should return 'true'`, async () => {
32
- const pfs = new PoweredFileSystem();
33
-
34
- const exist = await pfs.test('./tmpdir/libxbase');
35
- assert(exist);
36
- });
37
-
38
- it(`Positive: For existing file should return 'true'`, async () => {
39
- const pfs = new PoweredFileSystem();
40
-
41
- const exist = await pfs.test('./tmpdir/binapp');
42
- assert(exist);
43
- });
44
-
45
- it(`Positive: A non-existent file must return 'false'`, async () => {
46
- const pfs = new PoweredFileSystem();
47
- const chance = new Chance();
48
-
49
- const base = chance.guid();
50
- const exists = await pfs.test(`./${base}`);
51
-
52
- assert(exists === false);
53
- });
54
-
55
- it(`Positive: Should return 'true' for absolute source`, async () => {
56
- const pfs = new PoweredFileSystem();
57
-
58
- const cwd = process.cwd();
59
-
60
- const exists = await pfs.test(`${cwd}${sep}tmpdir`, {
61
- resolve: false
62
- });
63
-
64
- assert(exists);
65
- });
66
-
67
- describe('sync mode', () => {
68
- it(`Positive: For existing directory should return 'true'`, () => {
69
- const pfs = new PoweredFileSystem();
70
-
71
- const exist = pfs.test('./tmpdir/libxbase', {
72
- sync: true
73
- });
74
-
75
- assert(exist);
76
- });
77
-
78
- it(`Positive: For existing file should return 'true'`, () => {
79
- const pfs = new PoweredFileSystem();
80
-
81
- const exist = pfs.test('./tmpdir/binapp', {
82
- sync: true
83
- });
84
-
85
- assert(exist);
86
- });
87
-
88
- it(`Positive: A non-existent file must return 'false'`, async () => {
89
- const pfs = new PoweredFileSystem();
90
- const chance = new Chance();
91
-
92
- const base = chance.guid();
93
- const exists = pfs.test(`./${base}`, {
94
- sync: true
95
- });
96
-
97
- assert(exists === false);
98
- });
99
-
100
- it(`Positive: Should return 'true' for absolute source`, async () => {
101
- const pfs = new PoweredFileSystem();
102
-
103
- const cwd = process.cwd();
104
-
105
- const exists = pfs.test(`${cwd}${sep}tmpdir`, {
106
- sync: true,
107
- resolve: false
108
- });
109
-
110
- assert(exists);
111
- });
112
- });
113
- });
@@ -1,167 +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('write(src, data[, 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 write content to file', async () => {
25
- const pfs = new PoweredFileSystem();
26
- const chance = new Chance();
27
-
28
- const base = chance.guid();
29
- const exists = await pfs.test(`./tmpdir/${base}`);
30
-
31
- assert(exists === false);
32
-
33
- const payload = chance.paragraph();
34
-
35
- await pfs.write(`./tmpdir/${base}`, payload);
36
- const stats = await pfs.stat(`./tmpdir/${base}`);
37
-
38
- assert(stats.size > 0);
39
- });
40
-
41
- it('Positive: Must rewrite content if file already exists', async () => {
42
- const pfs = new PoweredFileSystem();
43
- const chance = new Chance();
44
-
45
- const payload = chance.paragraph();
46
-
47
- await pfs.write('./tmpdir/binapp', payload);
48
-
49
- const stats = await pfs.stat(`./tmpdir/binapp`);
50
- assert(stats.size > 0);
51
- });
52
-
53
- it(`Positive: Must write content to file, when path is absolute`, async () => {
54
- const pfs = new PoweredFileSystem();
55
- const chance = new Chance();
56
-
57
- const payload = chance.paragraph();
58
- const cwd = process.cwd();
59
-
60
- await pfs.write(`${cwd}${sep}tmpdir${sep}binapp`, payload, {
61
- resolve: false
62
- });
63
-
64
- const stats = await pfs.stat(`./tmpdir/binapp`);
65
- assert(stats.size > 0);
66
- });
67
-
68
- it('Negative: Throw if resource is directory', async () => {
69
- const pfs = new PoweredFileSystem();
70
- const chance = new Chance();
71
-
72
- try {
73
- const payload = chance.paragraph();
74
-
75
- await pfs.write('./tmpdir/libxbase', payload);
76
- }
77
- catch (err) {
78
- assert(err.errno === -21);
79
- }
80
- });
81
-
82
- it(`Negative: Unexpected option 'flag' returns Error`, async () => {
83
- const pfs = new PoweredFileSystem();
84
- const chance = new Chance();
85
-
86
- try {
87
- const payload = chance.paragraph();
88
-
89
- await pfs.write('./tmpdir/binapp', payload, {
90
- flag: 'r'
91
- });
92
- }
93
- catch (err) {
94
- assert(err.errno === -9);
95
- }
96
- });
97
-
98
- describe('sync mode', () => {
99
- it('Positive: Must write content to file', async () => {
100
- const pfs = new PoweredFileSystem();
101
- const chance = new Chance();
102
-
103
- const base = chance.guid();
104
- const exists = await pfs.test(`./tmpdir/${base}`);
105
-
106
- assert(exists === false);
107
-
108
- const payload = chance.paragraph();
109
-
110
- pfs.write(`./tmpdir/${base}`, payload, {
111
- sync: true
112
- });
113
-
114
- const stats = await pfs.stat(`./tmpdir/${base}`);
115
- assert(stats.size > 0);
116
- });
117
-
118
- it(`Positive: Must write content to file, when path is absolute`, async () => {
119
- const pfs = new PoweredFileSystem();
120
- const chance = new Chance();
121
-
122
- const payload = chance.paragraph();
123
- const cwd = process.cwd();
124
-
125
- pfs.write(`${cwd}${sep}tmpdir${sep}binapp`, payload, {
126
- sync: true,
127
- resolve: false
128
- });
129
-
130
- const stats = await pfs.stat(`./tmpdir/binapp`);
131
- assert(stats.size > 0);
132
- });
133
-
134
- it('Negative: Throw if resource is directory', async () => {
135
- const pfs = new PoweredFileSystem();
136
- const chance = new Chance();
137
-
138
- try {
139
- const payload = chance.paragraph();
140
-
141
- pfs.write('./tmpdir/libxbase', payload, {
142
- sync: true
143
- });
144
- }
145
- catch (err) {
146
- assert(err.errno === -21);
147
- }
148
- });
149
-
150
- it(`Negative: Unexpected option 'flag' returns Error`, async () => {
151
- const pfs = new PoweredFileSystem();
152
- const chance = new Chance();
153
-
154
- try {
155
- const payload = chance.paragraph();
156
-
157
- pfs.write('./tmpdir/binapp', payload, {
158
- sync: true,
159
- flag: 'r'
160
- });
161
- }
162
- catch (err) {
163
- assert(err.errno === -9);
164
- }
165
- });
166
- });
167
- });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes