pwd-fs 3.1.4 → 3.2.1

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 (52) hide show
  1. package/dist/src/bitmask.d.ts +1 -0
  2. package/dist/src/bitmask.js +18 -0
  3. package/{lib → dist}/src/powered-file-system.d.ts +20 -3
  4. package/{lib → dist}/src/powered-file-system.js +39 -41
  5. package/dist/src/recurse-io-sync.d.ts +5 -0
  6. package/{lib → dist}/src/recurse-io-sync.js +28 -23
  7. package/dist/src/recurse-io.d.ts +7 -0
  8. package/{lib → dist}/src/recurse-io.js +15 -10
  9. package/package.json +5 -5
  10. package/readme.md +4 -4
  11. package/src/bitmask.ts +20 -0
  12. package/src/powered-file-system.ts +48 -52
  13. package/src/recurse-io-sync.ts +24 -24
  14. package/src/recurse-io.ts +18 -19
  15. package/test/chown.spec.ts +16 -10
  16. package/tsconfig.json +2 -2
  17. package/lib/src/recurse-io-sync.d.ts +0 -13
  18. package/lib/src/recurse-io.d.ts +0 -17
  19. package/lib/test/__fmock.d.ts +0 -5
  20. package/lib/test/__fmock.js +0 -40
  21. package/lib/test/append.spec.d.ts +0 -1
  22. package/lib/test/append.spec.js +0 -58
  23. package/lib/test/bitmask.spec.d.ts +0 -1
  24. package/lib/test/bitmask.spec.js +0 -26
  25. package/lib/test/chmod.spec.d.ts +0 -1
  26. package/lib/test/chmod.spec.js +0 -62
  27. package/lib/test/chown.spec.d.ts +0 -1
  28. package/lib/test/chown.spec.js +0 -68
  29. package/lib/test/constructor.spec.d.ts +0 -1
  30. package/lib/test/constructor.spec.js +0 -17
  31. package/lib/test/copy.spec.d.ts +0 -1
  32. package/lib/test/copy.spec.js +0 -80
  33. package/lib/test/mkdir.spec.d.ts +0 -1
  34. package/lib/test/mkdir.spec.js +0 -90
  35. package/lib/test/read.spec.d.ts +0 -1
  36. package/lib/test/read.spec.js +0 -73
  37. package/lib/test/readdir.spec.d.ts +0 -1
  38. package/lib/test/readdir.spec.js +0 -70
  39. package/lib/test/remove.spec.d.ts +0 -1
  40. package/lib/test/remove.spec.js +0 -63
  41. package/lib/test/rename.spec.d.ts +0 -1
  42. package/lib/test/rename.spec.js +0 -66
  43. package/lib/test/stat.spec.d.ts +0 -1
  44. package/lib/test/stat.spec.js +0 -76
  45. package/lib/test/symlink.spec.d.ts +0 -1
  46. package/lib/test/symlink.spec.js +0 -74
  47. package/lib/test/test.spec.d.ts +0 -1
  48. package/lib/test/test.spec.js +0 -60
  49. package/lib/test/write.spec.d.ts +0 -1
  50. package/lib/test/write.spec.js +0 -82
  51. /package/{lib → dist}/src/index.d.ts +0 -0
  52. /package/{lib → dist}/src/index.js +0 -0
@@ -1,76 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_assert_1 = __importDefault(require("node:assert"));
7
- const chance_1 = __importDefault(require("chance"));
8
- const expect_1 = require("expect");
9
- const __fmock_1 = require("./__fmock");
10
- const src_1 = require("../src");
11
- describe('stat(src [, options])', () => {
12
- const chance = new chance_1.default();
13
- beforeEach(() => {
14
- const cwd = process.cwd();
15
- (0, __fmock_1.fmock)({
16
- './tmpdir/tings.txt': {
17
- type: 'file',
18
- data: chance.string()
19
- },
20
- './tmpdir/digest/': { type: 'directory' },
21
- './tmpdir/flexapp': {
22
- type: 'symlink',
23
- target: `${cwd}/tmpdir/tings.txt`
24
- }
25
- });
26
- });
27
- afterEach(() => {
28
- (0, __fmock_1.restore)('./tmpdir');
29
- });
30
- it('Positive: Must return information a file', async () => {
31
- const stats = await src_1.pfs.stat('./tmpdir/tings.txt');
32
- (0, node_assert_1.default)(stats.isFile());
33
- });
34
- it('Positive: Must return information a directory', async () => {
35
- const stats = await src_1.pfs.stat('./tmpdir/digest');
36
- (0, node_assert_1.default)(stats.isDirectory());
37
- });
38
- it('Positive: Must return information a symlink', async () => {
39
- const stats = await src_1.pfs.stat('./tmpdir/flexapp');
40
- (0, node_assert_1.default)(stats.isSymbolicLink());
41
- });
42
- it('Negative: Throw if not exists resource', async () => {
43
- const guid = chance.guid();
44
- await (0, expect_1.expect)(async () => {
45
- await src_1.pfs.stat(`./tmpdir/${guid}`);
46
- })
47
- .rejects
48
- .toThrow();
49
- });
50
- it('[sync] Positive: Must return information a file', () => {
51
- const stats = src_1.pfs.stat('./tmpdir/tings.txt', {
52
- sync: true
53
- });
54
- (0, node_assert_1.default)(stats.isFile());
55
- });
56
- it('[sync] Positive: Must return information a directory in ', () => {
57
- const stats = src_1.pfs.stat('./tmpdir/digest', {
58
- sync: true
59
- });
60
- (0, node_assert_1.default)(stats.isDirectory());
61
- });
62
- it('[sync] Positive: Must return information a symlink', () => {
63
- const stats = src_1.pfs.stat('./tmpdir/flexapp', {
64
- sync: true
65
- });
66
- (0, node_assert_1.default)(stats.isSymbolicLink());
67
- });
68
- it('[sync] Negative: Throw if not exists resource', () => {
69
- const guid = chance.guid();
70
- node_assert_1.default.throws(() => {
71
- src_1.pfs.stat(`./tmpdir/${guid}`, {
72
- sync: true
73
- });
74
- });
75
- });
76
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,74 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_assert_1 = __importDefault(require("node:assert"));
7
- const node_fs_1 = __importDefault(require("node:fs"));
8
- const chance_1 = __importDefault(require("chance"));
9
- const expect_1 = require("expect");
10
- const __fmock_1 = require("./__fmock");
11
- const src_1 = require("../src");
12
- describe('symlink(src, use [, options])', () => {
13
- const chance = new chance_1.default();
14
- beforeEach(() => {
15
- const cwd = process.cwd();
16
- const frame = {
17
- './tmpdir/tings.txt': {
18
- type: 'file',
19
- data: chance.string()
20
- },
21
- './tmpdir/digest/': { type: 'directory' },
22
- './tmpdir/flexapp': {
23
- type: 'symlink',
24
- target: `${cwd}/tmpdir/tings.txt`
25
- }
26
- };
27
- const counter = chance.natural({ max: 7 });
28
- for (let i = 0; i < counter; i++) {
29
- frame[`./tmpdir/${i}`] = { type: 'directory' };
30
- }
31
- (0, __fmock_1.fmock)(frame);
32
- });
33
- afterEach(() => {
34
- (0, __fmock_1.restore)('./tmpdir');
35
- });
36
- it('Positive: Must be created a symbolic link', async () => {
37
- await src_1.pfs.symlink('./tmpdir/tings.txt', './tmpdir/linkapp');
38
- const stat = node_fs_1.default.lstatSync('./tmpdir/linkapp');
39
- (0, node_assert_1.default)(stat.isSymbolicLink());
40
- });
41
- it('Positive: Must be created a symbolic link for directory', async () => {
42
- await src_1.pfs.symlink('./tmpdir/digest', './tmpdir/linkapp');
43
- const stat = node_fs_1.default.lstatSync('./tmpdir/linkapp');
44
- (0, node_assert_1.default)(stat.isSymbolicLink());
45
- });
46
- it('Negative: Throw if destination already exists', async () => {
47
- await (0, expect_1.expect)(async () => {
48
- await src_1.pfs.symlink('./tmpdir/tings.txt', './tmpdir/flexapp');
49
- })
50
- .rejects
51
- .toThrow();
52
- });
53
- it('[sync] Positive: Must be created a symbolic link', () => {
54
- src_1.pfs.symlink('./tmpdir/tings.txt', './tmpdir/linkapp', {
55
- sync: true
56
- });
57
- const stat = node_fs_1.default.lstatSync('./tmpdir/linkapp');
58
- (0, node_assert_1.default)(stat.isSymbolicLink());
59
- });
60
- it('[sync] Positive: Must be created a symbolic link for directory', () => {
61
- src_1.pfs.symlink('./tmpdir/digest', './tmpdir/linkapp', {
62
- sync: true
63
- });
64
- const stat = node_fs_1.default.lstatSync('./tmpdir/linkapp');
65
- (0, node_assert_1.default)(stat.isSymbolicLink());
66
- });
67
- it('[sync] Negative: Throw if destination already exists', () => {
68
- node_assert_1.default.throws(() => {
69
- src_1.pfs.symlink('./tmpdir/tings.txt', './tmpdir/flexapp', {
70
- sync: true
71
- });
72
- });
73
- });
74
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_assert_1 = __importDefault(require("node:assert"));
7
- const chance_1 = __importDefault(require("chance"));
8
- const __fmock_1 = require("./__fmock");
9
- const src_1 = require("../src");
10
- describe('test(src[, options])', () => {
11
- const chance = new chance_1.default();
12
- beforeEach(() => {
13
- (0, __fmock_1.fmock)({
14
- './tmpdir/tings.txt': {
15
- type: 'file',
16
- data: chance.string()
17
- },
18
- './tmpdir/digest/': { type: 'directory' }
19
- });
20
- });
21
- afterEach(() => {
22
- (0, __fmock_1.restore)('./tmpdir');
23
- });
24
- it(`Positive: Should return 'true' for current working directory`, async () => {
25
- const exist = await src_1.pfs.test('.');
26
- (0, node_assert_1.default)(exist);
27
- });
28
- it(`Positive: For existing file should return 'true'`, async () => {
29
- const exist = await src_1.pfs.test('./tmpdir/tings.txt');
30
- (0, node_assert_1.default)(exist);
31
- });
32
- it(`Positive: For existing directory should return 'true'`, async () => {
33
- const exist = await src_1.pfs.test('./tmpdir/digest');
34
- (0, node_assert_1.default)(exist);
35
- });
36
- it(`Positive: A non-existent file must return 'false'`, async () => {
37
- const guid = chance.guid();
38
- const exist = await src_1.pfs.test(`./tmpdir/${guid}`);
39
- (0, node_assert_1.default)(exist === false);
40
- });
41
- it(`Positive: For existing file should return 'true'`, () => {
42
- const exist = src_1.pfs.test('./tmpdir/tings.txt', {
43
- sync: true
44
- });
45
- (0, node_assert_1.default)(exist);
46
- });
47
- it(`[sync] Positive: For existing directory should return 'true'`, () => {
48
- const exist = src_1.pfs.test('./tmpdir/digest', {
49
- sync: true
50
- });
51
- (0, node_assert_1.default)(exist);
52
- });
53
- it(`[sync] Positive: A non-existent file must return 'false'`, () => {
54
- const guid = chance.guid();
55
- const exist = src_1.pfs.test(`./tmpdir/${guid}`, {
56
- sync: true
57
- });
58
- (0, node_assert_1.default)(exist === false);
59
- });
60
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,82 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const node_assert_1 = __importDefault(require("node:assert"));
7
- const node_fs_1 = __importDefault(require("node:fs"));
8
- const chance_1 = __importDefault(require("chance"));
9
- const expect_1 = require("expect");
10
- const __fmock_1 = require("./__fmock");
11
- const src_1 = require("../src");
12
- describe('write(src, data[, options])', () => {
13
- const chance = new chance_1.default();
14
- beforeEach(() => {
15
- (0, __fmock_1.fmock)({
16
- './tmpdir/tings.txt': {
17
- type: 'file',
18
- data: chance.string()
19
- }
20
- });
21
- });
22
- afterEach(() => {
23
- (0, __fmock_1.restore)('./tmpdir');
24
- });
25
- it('Positive: Must write content to file', async () => {
26
- const payload = chance.paragraph();
27
- const guid = chance.guid();
28
- await src_1.pfs.write(`./tmpdir/${guid}.txt`, payload);
29
- const { size } = node_fs_1.default.lstatSync(`./tmpdir/${guid}.txt`);
30
- (0, node_assert_1.default)(payload.length === size);
31
- });
32
- it('Positive: Must rewrite content if file already exists', async () => {
33
- const payload = chance.paragraph();
34
- await src_1.pfs.write('./tmpdir/tings.txt', payload);
35
- const { size } = node_fs_1.default.lstatSync('./tmpdir/tings.txt');
36
- (0, node_assert_1.default)(payload.length === size);
37
- });
38
- it('Negative: Throw if resource is directory', async () => {
39
- const payload = chance.paragraph();
40
- await (0, expect_1.expect)(async () => {
41
- await src_1.pfs.write('./tmpdir', payload);
42
- })
43
- .rejects
44
- .toThrow();
45
- });
46
- it(`Negative: Unexpected option 'flag' returns Error`, async () => {
47
- const payload = chance.paragraph();
48
- await (0, expect_1.expect)(async () => {
49
- await src_1.pfs.write('./tmpdir/tings.txt', payload, {
50
- flag: 'r'
51
- });
52
- })
53
- .rejects
54
- .toThrow();
55
- });
56
- it('[sync] Positive: Write contents even to a non-existent file', () => {
57
- const payload = chance.paragraph();
58
- const guid = chance.guid();
59
- src_1.pfs.write(`./tmpdir/${guid}.txt`, payload, {
60
- sync: true
61
- });
62
- const content = node_fs_1.default.readFileSync(`./tmpdir/${guid}.txt`, 'utf8');
63
- (0, node_assert_1.default)(payload === content);
64
- });
65
- it('[sync] Negative: Throw if resource is directory', () => {
66
- const payload = chance.paragraph();
67
- node_assert_1.default.throws(() => {
68
- src_1.pfs.write('./tmpdir', payload, {
69
- sync: true
70
- });
71
- });
72
- });
73
- it(`[sync] Negative: Unexpected option 'flag' returns Error`, () => {
74
- const payload = chance.paragraph();
75
- node_assert_1.default.throws(() => {
76
- src_1.pfs.write('./tmpdir/tings.txt', payload, {
77
- sync: true,
78
- flag: 'r'
79
- });
80
- });
81
- });
82
- });
File without changes
File without changes