pwd-fs 3.5.4 → 3.5.6

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 (82) hide show
  1. package/dist/bitmask.d.ts +10 -0
  2. package/dist/bitmask.js +10 -0
  3. package/dist/powered-file-system/append.d.ts +10 -0
  4. package/dist/powered-file-system/append.js +10 -0
  5. package/dist/powered-file-system/chmod.d.ts +10 -0
  6. package/dist/powered-file-system/chmod.js +10 -0
  7. package/dist/powered-file-system/chown.d.ts +10 -0
  8. package/dist/powered-file-system/chown.js +10 -0
  9. package/dist/powered-file-system/copy.d.ts +10 -0
  10. package/dist/powered-file-system/copy.js +10 -0
  11. package/dist/powered-file-system/empty-dir.d.ts +10 -0
  12. package/dist/powered-file-system/empty-dir.js +10 -0
  13. package/dist/powered-file-system/mkdir.d.ts +10 -0
  14. package/dist/powered-file-system/mkdir.js +10 -0
  15. package/dist/powered-file-system/read.d.ts +10 -0
  16. package/dist/powered-file-system/read.js +10 -0
  17. package/dist/powered-file-system/readdir.d.ts +10 -0
  18. package/dist/powered-file-system/readdir.js +10 -0
  19. package/dist/powered-file-system/readlink.d.ts +10 -0
  20. package/dist/powered-file-system/readlink.js +10 -0
  21. package/dist/powered-file-system/realpath.d.ts +10 -0
  22. package/dist/powered-file-system/realpath.js +10 -0
  23. package/dist/powered-file-system/remove.d.ts +10 -0
  24. package/dist/powered-file-system/remove.js +10 -0
  25. package/dist/powered-file-system/rename.d.ts +10 -0
  26. package/dist/powered-file-system/rename.js +10 -0
  27. package/dist/powered-file-system/stat.d.ts +10 -0
  28. package/dist/powered-file-system/stat.js +10 -0
  29. package/dist/powered-file-system/symlink.d.ts +10 -0
  30. package/dist/powered-file-system/symlink.js +10 -0
  31. package/dist/powered-file-system/test.d.ts +10 -0
  32. package/dist/powered-file-system/test.js +10 -0
  33. package/dist/powered-file-system/write.d.ts +10 -0
  34. package/dist/powered-file-system/write.js +10 -0
  35. package/dist/powered-file-system.d.ts +10 -0
  36. package/dist/powered-file-system.js +10 -0
  37. package/dist/recurse-io-sync.d.ts +10 -0
  38. package/dist/recurse-io-sync.js +10 -0
  39. package/dist/recurse-io.d.ts +10 -0
  40. package/dist/recurse-io.js +10 -0
  41. package/package.json +8 -19
  42. package/readme.md +273 -426
  43. package/dist/bitmask.test.d.ts +0 -1
  44. package/dist/bitmask.test.js +0 -29
  45. package/dist/powered-file-system/append.test.d.ts +0 -1
  46. package/dist/powered-file-system/append.test.js +0 -47
  47. package/dist/powered-file-system/chmod.test.d.ts +0 -1
  48. package/dist/powered-file-system/chmod.test.js +0 -71
  49. package/dist/powered-file-system/chown.test.d.ts +0 -1
  50. package/dist/powered-file-system/chown.test.js +0 -82
  51. package/dist/powered-file-system/copy.test.d.ts +0 -1
  52. package/dist/powered-file-system/copy.test.js +0 -128
  53. package/dist/powered-file-system/empty-dir.test.d.ts +0 -1
  54. package/dist/powered-file-system/empty-dir.test.js +0 -61
  55. package/dist/powered-file-system/mkdir.test.d.ts +0 -1
  56. package/dist/powered-file-system/mkdir.test.js +0 -116
  57. package/dist/powered-file-system/read.test.d.ts +0 -1
  58. package/dist/powered-file-system/read.test.js +0 -75
  59. package/dist/powered-file-system/readdir.test.d.ts +0 -1
  60. package/dist/powered-file-system/readdir.test.js +0 -72
  61. package/dist/powered-file-system/readlink.test.d.ts +0 -1
  62. package/dist/powered-file-system/readlink.test.js +0 -44
  63. package/dist/powered-file-system/realpath.test.d.ts +0 -1
  64. package/dist/powered-file-system/realpath.test.js +0 -44
  65. package/dist/powered-file-system/remove.test.d.ts +0 -1
  66. package/dist/powered-file-system/remove.test.js +0 -78
  67. package/dist/powered-file-system/rename.test.d.ts +0 -1
  68. package/dist/powered-file-system/rename.test.js +0 -70
  69. package/dist/powered-file-system/stat.test.d.ts +0 -1
  70. package/dist/powered-file-system/stat.test.js +0 -79
  71. package/dist/powered-file-system/symlink.test.d.ts +0 -1
  72. package/dist/powered-file-system/symlink.test.js +0 -77
  73. package/dist/powered-file-system/test.test.d.ts +0 -1
  74. package/dist/powered-file-system/test.test.js +0 -76
  75. package/dist/powered-file-system/write.test.d.ts +0 -1
  76. package/dist/powered-file-system/write.test.js +0 -97
  77. package/dist/powered-file-system.test.d.ts +0 -1
  78. package/dist/powered-file-system.test.js +0 -46
  79. package/dist/suite.test.d.ts +0 -1
  80. package/dist/suite.test.js +0 -40
  81. package/dist/test-utils.d.ts +0 -18
  82. package/dist/test-utils.js +0 -72
@@ -1,72 +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_path_1 = __importDefault(require("node:path"));
8
- const chance_1 = __importDefault(require("chance"));
9
- const node_test_1 = require("node:test");
10
- const index_1 = require("../index");
11
- const test_utils_1 = require("../test-utils");
12
- /**
13
- * Verifies directory listing behavior and invalid-target failures.
14
- */
15
- (0, node_test_1.describe)('readdir(src[, options])', () => {
16
- const chance = new chance_1.default();
17
- let counter = 0;
18
- let tmpDir = '';
19
- (0, node_test_1.beforeEach)(() => {
20
- tmpDir = (0, test_utils_1.createTmpDir)();
21
- const frame = {
22
- [node_path_1.default.join(tmpDir, 'tings.txt')]: {
23
- type: 'file',
24
- data: chance.string()
25
- }
26
- };
27
- counter = chance.natural({ max: 7 });
28
- for (let i = 0; i < counter; i++) {
29
- frame[node_path_1.default.join(tmpDir, String(i))] = { type: 'directory' };
30
- }
31
- (0, test_utils_1.fmock)(frame);
32
- });
33
- (0, node_test_1.afterEach)(() => {
34
- (0, test_utils_1.restore)(tmpDir);
35
- });
36
- (0, node_test_1.it)('Positive: Must return a directory listing', async () => {
37
- const { length } = await index_1.pfs.readdir(tmpDir);
38
- (0, node_assert_1.default)(counter + 1 === length);
39
- });
40
- (0, node_test_1.it)('Negative: Throw if resource is not directory', async () => {
41
- await node_assert_1.default.rejects(async () => {
42
- await index_1.pfs.readdir(node_path_1.default.join(tmpDir, 'tings.txt'));
43
- });
44
- });
45
- (0, node_test_1.it)('Negative: Throw if not exists resource', async () => {
46
- const guid = chance.guid();
47
- await node_assert_1.default.rejects(async () => {
48
- await index_1.pfs.readdir(node_path_1.default.join(tmpDir, guid));
49
- });
50
- });
51
- (0, node_test_1.it)('[sync] Positive: Must return a directory listing', () => {
52
- const { length } = index_1.pfs.readdir(tmpDir, {
53
- sync: true
54
- });
55
- (0, node_assert_1.default)(counter + 1 === length);
56
- });
57
- (0, node_test_1.it)('Negative: Throw if resource is not directory', () => {
58
- node_assert_1.default.throws(() => {
59
- index_1.pfs.readdir(node_path_1.default.join(tmpDir, 'tings.txt'), {
60
- sync: true
61
- });
62
- });
63
- });
64
- (0, node_test_1.it)('Negative: Throw if not exists resource', () => {
65
- const guid = chance.guid();
66
- node_assert_1.default.throws(() => {
67
- index_1.pfs.readdir(node_path_1.default.join(tmpDir, guid), {
68
- sync: true
69
- });
70
- });
71
- });
72
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,44 +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_path_1 = __importDefault(require("node:path"));
8
- const chance_1 = __importDefault(require("chance"));
9
- const node_test_1 = require("node:test");
10
- const index_1 = require("../index");
11
- const test_utils_1 = require("../test-utils");
12
- /**
13
- * Verifies symbolic link target resolution without dereferencing it.
14
- */
15
- (0, node_test_1.describe)('readlink(src [, options])', () => {
16
- const chance = new chance_1.default();
17
- let tmpDir = '';
18
- (0, node_test_1.beforeEach)(() => {
19
- tmpDir = (0, test_utils_1.createTmpDir)();
20
- (0, test_utils_1.fmock)({
21
- [node_path_1.default.join(tmpDir, 'tings.txt')]: {
22
- type: 'file',
23
- data: chance.string()
24
- },
25
- [node_path_1.default.join(tmpDir, 'flexapp')]: {
26
- type: 'symlink',
27
- target: node_path_1.default.join(tmpDir, 'tings.txt')
28
- }
29
- });
30
- });
31
- (0, node_test_1.afterEach)(() => {
32
- (0, test_utils_1.restore)(tmpDir);
33
- });
34
- (0, node_test_1.it)('Positive: Reads the stored symlink target', async () => {
35
- const target = await index_1.pfs.readlink(node_path_1.default.join(tmpDir, 'flexapp'));
36
- (0, node_assert_1.default)(target === node_path_1.default.join(tmpDir, 'tings.txt'));
37
- });
38
- (0, node_test_1.it)('[sync] Positive: Reads the stored symlink target', () => {
39
- const target = index_1.pfs.readlink(node_path_1.default.join(tmpDir, 'flexapp'), {
40
- sync: true
41
- });
42
- (0, node_assert_1.default)(target === node_path_1.default.join(tmpDir, 'tings.txt'));
43
- });
44
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,44 +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_path_1 = __importDefault(require("node:path"));
8
- const chance_1 = __importDefault(require("chance"));
9
- const node_test_1 = require("node:test");
10
- const index_1 = require("../index");
11
- const test_utils_1 = require("../test-utils");
12
- /**
13
- * Verifies canonical path resolution through symbolic links.
14
- */
15
- (0, node_test_1.describe)('realpath(src [, options])', () => {
16
- const chance = new chance_1.default();
17
- let tmpDir = '';
18
- (0, node_test_1.beforeEach)(() => {
19
- tmpDir = (0, test_utils_1.createTmpDir)();
20
- (0, test_utils_1.fmock)({
21
- [node_path_1.default.join(tmpDir, 'tings.txt')]: {
22
- type: 'file',
23
- data: chance.string()
24
- },
25
- [node_path_1.default.join(tmpDir, 'flexapp')]: {
26
- type: 'symlink',
27
- target: node_path_1.default.join(tmpDir, 'tings.txt')
28
- }
29
- });
30
- });
31
- (0, node_test_1.afterEach)(() => {
32
- (0, test_utils_1.restore)(tmpDir);
33
- });
34
- (0, node_test_1.it)('Positive: Resolves the canonical target path', async () => {
35
- const target = await index_1.pfs.realpath(node_path_1.default.join(tmpDir, 'flexapp'));
36
- (0, node_assert_1.default)(target === node_path_1.default.join(tmpDir, 'tings.txt'));
37
- });
38
- (0, node_test_1.it)('[sync] Positive: Resolves the canonical target path', () => {
39
- const target = index_1.pfs.realpath(node_path_1.default.join(tmpDir, 'flexapp'), {
40
- sync: true
41
- });
42
- (0, node_assert_1.default)(target === node_path_1.default.join(tmpDir, 'tings.txt'));
43
- });
44
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,78 +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 node_path_1 = __importDefault(require("node:path"));
9
- const chance_1 = __importDefault(require("chance"));
10
- const node_test_1 = require("node:test");
11
- const index_1 = require("../index");
12
- const test_utils_1 = require("../test-utils");
13
- /**
14
- * Covers recursive removal, including the symlink edge case.
15
- */
16
- (0, node_test_1.describe)('remove(src [, options])', () => {
17
- const chance = new chance_1.default();
18
- let tmpDir = '';
19
- (0, node_test_1.beforeEach)(() => {
20
- tmpDir = (0, test_utils_1.createTmpDir)();
21
- const frame = {
22
- [node_path_1.default.join(tmpDir, 'tings.txt')]: {
23
- type: 'file',
24
- data: chance.string()
25
- },
26
- [node_path_1.default.join(tmpDir, 'digest')]: { type: 'directory' },
27
- [node_path_1.default.join(tmpDir, 'flexapp')]: {
28
- type: 'symlink',
29
- target: node_path_1.default.join(tmpDir, 'tings.txt')
30
- },
31
- [node_path_1.default.join(tmpDir, 'digest-link')]: {
32
- type: 'symlink',
33
- target: node_path_1.default.join(tmpDir, 'digest')
34
- }
35
- };
36
- const counter = chance.natural({ max: 7 });
37
- for (let i = 0; i < counter; i++) {
38
- frame[node_path_1.default.join(tmpDir, String(i))] = { type: 'directory' };
39
- }
40
- (0, test_utils_1.fmock)(frame);
41
- });
42
- (0, node_test_1.afterEach)(() => {
43
- (0, test_utils_1.restore)(tmpDir);
44
- });
45
- (0, node_test_1.it)('Positive: Removal a directory with a file', async () => {
46
- await index_1.pfs.remove(tmpDir);
47
- const exist = node_fs_1.default.existsSync(tmpDir);
48
- (0, node_assert_1.default)(exist === false);
49
- });
50
- (0, node_test_1.it)('Negative: Throw if not exists resource', async () => {
51
- const guid = chance.guid();
52
- await node_assert_1.default.rejects(async () => {
53
- await index_1.pfs.remove(node_path_1.default.join(tmpDir, guid));
54
- });
55
- });
56
- (0, node_test_1.it)('[sync] Positive: Removal a directory with a file', () => {
57
- index_1.pfs.remove(tmpDir, {
58
- sync: true
59
- });
60
- const exist = node_fs_1.default.existsSync(tmpDir);
61
- (0, node_assert_1.default)(exist === false);
62
- });
63
- (0, node_test_1.it)('[sync] Negative: Throw if not exists resource', () => {
64
- const guid = chance.guid();
65
- node_assert_1.default.throws(() => {
66
- index_1.pfs.remove(node_path_1.default.join(tmpDir, guid), {
67
- sync: true
68
- });
69
- });
70
- });
71
- (0, node_test_1.it)('[sync] Positive: Removing a symlink to a directory should remove only the link', () => {
72
- index_1.pfs.remove(node_path_1.default.join(tmpDir, 'digest-link'), {
73
- sync: true
74
- });
75
- (0, node_assert_1.default)(node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'digest-link')) === false);
76
- (0, node_assert_1.default)(node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'digest')));
77
- });
78
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,70 +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 node_path_1 = __importDefault(require("node:path"));
9
- const chance_1 = __importDefault(require("chance"));
10
- const node_test_1 = require("node:test");
11
- const index_1 = require("../index");
12
- const test_utils_1 = require("../test-utils");
13
- /**
14
- * Verifies move semantics for both files and directories.
15
- */
16
- (0, node_test_1.describe)('rename(src, use [, options])', () => {
17
- const chance = new chance_1.default();
18
- let tmpDir = '';
19
- (0, node_test_1.beforeEach)(() => {
20
- tmpDir = (0, test_utils_1.createTmpDir)();
21
- (0, test_utils_1.fmock)({
22
- [node_path_1.default.join(tmpDir, 'tings.txt')]: {
23
- type: 'file',
24
- data: chance.string()
25
- },
26
- [node_path_1.default.join(tmpDir, 'digest')]: { type: 'directory' }
27
- });
28
- });
29
- (0, node_test_1.afterEach)(() => {
30
- (0, test_utils_1.restore)(tmpDir);
31
- });
32
- (0, node_test_1.it)('Positive: Must be recursive rename file', async () => {
33
- await index_1.pfs.rename(node_path_1.default.join(tmpDir, 'tings.txt'), node_path_1.default.join(tmpDir, 'newapp.txt'));
34
- const exist = node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'newapp.txt'));
35
- (0, node_assert_1.default)(exist);
36
- });
37
- (0, node_test_1.it)('Positive: Must be recursive rename directory', async () => {
38
- await index_1.pfs.rename(node_path_1.default.join(tmpDir, 'digest'), node_path_1.default.join(tmpDir, 'newxbase'));
39
- const exist = node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'newxbase'));
40
- (0, node_assert_1.default)(exist);
41
- });
42
- (0, node_test_1.it)('Negative: Throw if not exists resource', async () => {
43
- const guid = chance.guid();
44
- await node_assert_1.default.rejects(async () => {
45
- await index_1.pfs.rename(node_path_1.default.join(tmpDir, guid), node_path_1.default.join(tmpDir, 'newxbase'));
46
- });
47
- });
48
- (0, node_test_1.it)('[sync] Positive: Must be recursive rename file', () => {
49
- index_1.pfs.rename(node_path_1.default.join(tmpDir, 'tings.txt'), node_path_1.default.join(tmpDir, 'newapp.txt'), {
50
- sync: true
51
- });
52
- const exist = node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'newapp.txt'));
53
- (0, node_assert_1.default)(exist);
54
- });
55
- (0, node_test_1.it)('[sync] Positive: Must be recursive rename directory', () => {
56
- index_1.pfs.rename(node_path_1.default.join(tmpDir, 'digest'), node_path_1.default.join(tmpDir, 'newxbase'), {
57
- sync: true
58
- });
59
- const exist = node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'newxbase'));
60
- (0, node_assert_1.default)(exist);
61
- });
62
- (0, node_test_1.it)('[sync] Negative: Throw if not exists resource', () => {
63
- const guid = chance.guid();
64
- node_assert_1.default.throws(() => {
65
- index_1.pfs.rename(node_path_1.default.join(tmpDir, guid), node_path_1.default.join(tmpDir, 'newxbase'), {
66
- sync: true
67
- });
68
- });
69
- });
70
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,79 +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_path_1 = __importDefault(require("node:path"));
8
- const chance_1 = __importDefault(require("chance"));
9
- const node_test_1 = require("node:test");
10
- const index_1 = require("../index");
11
- const test_utils_1 = require("../test-utils");
12
- /**
13
- * Ensures `stat()` preserves file type reporting for files, directories, and symlinks.
14
- */
15
- (0, node_test_1.describe)('stat(src [, options])', () => {
16
- const chance = new chance_1.default();
17
- let tmpDir = '';
18
- (0, node_test_1.beforeEach)(() => {
19
- tmpDir = (0, test_utils_1.createTmpDir)();
20
- (0, test_utils_1.fmock)({
21
- [node_path_1.default.join(tmpDir, 'tings.txt')]: {
22
- type: 'file',
23
- data: chance.string()
24
- },
25
- [node_path_1.default.join(tmpDir, 'digest')]: { type: 'directory' },
26
- [node_path_1.default.join(tmpDir, 'flexapp')]: {
27
- type: 'symlink',
28
- target: node_path_1.default.join(tmpDir, 'tings.txt')
29
- }
30
- });
31
- });
32
- (0, node_test_1.afterEach)(() => {
33
- (0, test_utils_1.restore)(tmpDir);
34
- });
35
- (0, node_test_1.it)('Positive: Must return information a file', async () => {
36
- const stats = await index_1.pfs.stat(node_path_1.default.join(tmpDir, 'tings.txt'));
37
- (0, node_assert_1.default)(stats.isFile());
38
- });
39
- (0, node_test_1.it)('Positive: Must return information a directory', async () => {
40
- const stats = await index_1.pfs.stat(node_path_1.default.join(tmpDir, 'digest'));
41
- (0, node_assert_1.default)(stats.isDirectory());
42
- });
43
- (0, node_test_1.it)('Positive: Must return information a symlink', async () => {
44
- const stats = await index_1.pfs.stat(node_path_1.default.join(tmpDir, 'flexapp'));
45
- (0, node_assert_1.default)(stats.isSymbolicLink());
46
- });
47
- (0, node_test_1.it)('Negative: Throw if not exists resource', async () => {
48
- const guid = chance.guid();
49
- await node_assert_1.default.rejects(async () => {
50
- await index_1.pfs.stat(node_path_1.default.join(tmpDir, guid));
51
- });
52
- });
53
- (0, node_test_1.it)('[sync] Positive: Must return information a file', () => {
54
- const stats = index_1.pfs.stat(node_path_1.default.join(tmpDir, 'tings.txt'), {
55
- sync: true
56
- });
57
- (0, node_assert_1.default)(stats.isFile());
58
- });
59
- (0, node_test_1.it)('[sync] Positive: Must return information a directory in ', () => {
60
- const stats = index_1.pfs.stat(node_path_1.default.join(tmpDir, 'digest'), {
61
- sync: true
62
- });
63
- (0, node_assert_1.default)(stats.isDirectory());
64
- });
65
- (0, node_test_1.it)('[sync] Positive: Must return information a symlink', () => {
66
- const stats = index_1.pfs.stat(node_path_1.default.join(tmpDir, 'flexapp'), {
67
- sync: true
68
- });
69
- (0, node_assert_1.default)(stats.isSymbolicLink());
70
- });
71
- (0, node_test_1.it)('[sync] Negative: Throw if not exists resource', () => {
72
- const guid = chance.guid();
73
- node_assert_1.default.throws(() => {
74
- index_1.pfs.stat(node_path_1.default.join(tmpDir, guid), {
75
- sync: true
76
- });
77
- });
78
- });
79
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,77 +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 node_path_1 = __importDefault(require("node:path"));
9
- const chance_1 = __importDefault(require("chance"));
10
- const node_test_1 = require("node:test");
11
- const index_1 = require("../index");
12
- const test_utils_1 = require("../test-utils");
13
- /**
14
- * Covers symlink creation for file and directory targets.
15
- */
16
- (0, node_test_1.describe)('symlink(src, use [, options])', () => {
17
- const chance = new chance_1.default();
18
- let tmpDir = '';
19
- (0, node_test_1.beforeEach)(() => {
20
- tmpDir = (0, test_utils_1.createTmpDir)();
21
- const frame = {
22
- [node_path_1.default.join(tmpDir, 'tings.txt')]: {
23
- type: 'file',
24
- data: chance.string()
25
- },
26
- [node_path_1.default.join(tmpDir, 'digest')]: { type: 'directory' },
27
- [node_path_1.default.join(tmpDir, 'flexapp')]: {
28
- type: 'symlink',
29
- target: node_path_1.default.join(tmpDir, 'tings.txt')
30
- }
31
- };
32
- const counter = chance.natural({ max: 7 });
33
- for (let i = 0; i < counter; i++) {
34
- frame[node_path_1.default.join(tmpDir, String(i))] = { type: 'directory' };
35
- }
36
- (0, test_utils_1.fmock)(frame);
37
- });
38
- (0, node_test_1.afterEach)(() => {
39
- (0, test_utils_1.restore)(tmpDir);
40
- });
41
- (0, node_test_1.it)('Positive: Must be created a symbolic link', async () => {
42
- await index_1.pfs.symlink(node_path_1.default.join(tmpDir, 'tings.txt'), node_path_1.default.join(tmpDir, 'linkapp'));
43
- const stat = node_fs_1.default.lstatSync(node_path_1.default.join(tmpDir, 'linkapp'));
44
- (0, node_assert_1.default)(stat.isSymbolicLink());
45
- });
46
- (0, node_test_1.it)('Positive: Must be created a symbolic link for directory', async () => {
47
- await index_1.pfs.symlink(node_path_1.default.join(tmpDir, 'digest'), node_path_1.default.join(tmpDir, 'linkapp'));
48
- const stat = node_fs_1.default.lstatSync(node_path_1.default.join(tmpDir, 'linkapp'));
49
- (0, node_assert_1.default)(stat.isSymbolicLink());
50
- });
51
- (0, node_test_1.it)('Negative: Throw if destination already exists', async () => {
52
- await node_assert_1.default.rejects(async () => {
53
- await index_1.pfs.symlink(node_path_1.default.join(tmpDir, 'tings.txt'), node_path_1.default.join(tmpDir, 'flexapp'));
54
- });
55
- });
56
- (0, node_test_1.it)('[sync] Positive: Must be created a symbolic link', () => {
57
- index_1.pfs.symlink(node_path_1.default.join(tmpDir, 'tings.txt'), node_path_1.default.join(tmpDir, 'linkapp'), {
58
- sync: true
59
- });
60
- const stat = node_fs_1.default.lstatSync(node_path_1.default.join(tmpDir, 'linkapp'));
61
- (0, node_assert_1.default)(stat.isSymbolicLink());
62
- });
63
- (0, node_test_1.it)('[sync] Positive: Must be created a symbolic link for directory', () => {
64
- index_1.pfs.symlink(node_path_1.default.join(tmpDir, 'digest'), node_path_1.default.join(tmpDir, 'linkapp'), {
65
- sync: true
66
- });
67
- const stat = node_fs_1.default.lstatSync(node_path_1.default.join(tmpDir, 'linkapp'));
68
- (0, node_assert_1.default)(stat.isSymbolicLink());
69
- });
70
- (0, node_test_1.it)('[sync] Negative: Throw if destination already exists', () => {
71
- node_assert_1.default.throws(() => {
72
- index_1.pfs.symlink(node_path_1.default.join(tmpDir, 'tings.txt'), node_path_1.default.join(tmpDir, 'flexapp'), {
73
- sync: true
74
- });
75
- });
76
- });
77
- });
@@ -1 +0,0 @@
1
- export {};
@@ -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 node_fs_1 = __importDefault(require("node:fs"));
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const chance_1 = __importDefault(require("chance"));
10
- const node_test_1 = require("node:test");
11
- const index_1 = require("../index");
12
- const test_utils_1 = require("../test-utils");
13
- /**
14
- * Verifies existence and access checks exposed by `test()`.
15
- */
16
- (0, node_test_1.describe)('test(src[, options])', () => {
17
- const chance = new chance_1.default();
18
- let tmpDir = '';
19
- (0, node_test_1.beforeEach)(() => {
20
- tmpDir = (0, test_utils_1.createTmpDir)();
21
- (0, test_utils_1.fmock)({
22
- [node_path_1.default.join(tmpDir, 'tings.txt')]: {
23
- type: 'file',
24
- data: chance.string()
25
- },
26
- [node_path_1.default.join(tmpDir, 'digest')]: { type: 'directory' }
27
- });
28
- });
29
- (0, node_test_1.afterEach)(() => {
30
- (0, test_utils_1.restore)(tmpDir);
31
- });
32
- (0, node_test_1.it)(`Positive: Should return 'true' for current working directory`, async () => {
33
- const exist = await index_1.pfs.test('.');
34
- (0, node_assert_1.default)(exist);
35
- });
36
- (0, node_test_1.it)(`Positive: For existing file should return 'true'`, async () => {
37
- const exist = await index_1.pfs.test(node_path_1.default.join(tmpDir, 'tings.txt'));
38
- (0, node_assert_1.default)(exist);
39
- });
40
- (0, node_test_1.it)(`Positive: For existing directory should return 'true'`, async () => {
41
- const exist = await index_1.pfs.test(node_path_1.default.join(tmpDir, 'digest'));
42
- (0, node_assert_1.default)(exist);
43
- });
44
- (0, node_test_1.it)(`Positive: A non-existent file must return 'false'`, async () => {
45
- const guid = chance.guid();
46
- const exist = await index_1.pfs.test(node_path_1.default.join(tmpDir, guid));
47
- (0, node_assert_1.default)(exist === false);
48
- });
49
- (0, node_test_1.it)(`Positive: For existing file should return 'true'`, () => {
50
- const exist = index_1.pfs.test(node_path_1.default.join(tmpDir, 'tings.txt'), {
51
- sync: true
52
- });
53
- (0, node_assert_1.default)(exist);
54
- });
55
- (0, node_test_1.it)(`[sync] Positive: For existing directory should return 'true'`, () => {
56
- const exist = index_1.pfs.test(node_path_1.default.join(tmpDir, 'digest'), {
57
- sync: true
58
- });
59
- (0, node_assert_1.default)(exist);
60
- });
61
- (0, node_test_1.it)(`[sync] Positive: A non-existent file must return 'false'`, () => {
62
- const guid = chance.guid();
63
- const exist = index_1.pfs.test(node_path_1.default.join(tmpDir, guid), {
64
- sync: true
65
- });
66
- (0, node_assert_1.default)(exist === false);
67
- });
68
- (0, node_test_1.it)('[sync] Positive: Should respect access flag checks', () => {
69
- node_fs_1.default.chmodSync(node_path_1.default.join(tmpDir, 'tings.txt'), 0o444);
70
- const writable = index_1.pfs.test(node_path_1.default.join(tmpDir, 'tings.txt'), {
71
- sync: true,
72
- flag: 'w'
73
- });
74
- (0, node_assert_1.default)(writable === false);
75
- });
76
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,97 +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 node_path_1 = __importDefault(require("node:path"));
9
- const chance_1 = __importDefault(require("chance"));
10
- const node_test_1 = require("node:test");
11
- const index_1 = require("../index");
12
- const test_utils_1 = require("../test-utils");
13
- /**
14
- * Covers file writes, overwrite behavior, and explicit mode handling.
15
- */
16
- const itUnix = process.platform === 'win32' ? node_test_1.it.skip : node_test_1.it;
17
- (0, node_test_1.describe)('write(src, data[, options])', () => {
18
- const chance = new chance_1.default();
19
- let tmpDir = '';
20
- (0, node_test_1.beforeEach)(() => {
21
- tmpDir = (0, test_utils_1.createTmpDir)();
22
- (0, test_utils_1.fmock)({
23
- [node_path_1.default.join(tmpDir, 'tings.txt')]: {
24
- type: 'file',
25
- data: chance.string()
26
- }
27
- });
28
- });
29
- (0, node_test_1.afterEach)(() => {
30
- (0, test_utils_1.restore)(tmpDir);
31
- });
32
- (0, node_test_1.it)('Positive: Must write content to file', async () => {
33
- const payload = chance.paragraph();
34
- const guid = chance.guid();
35
- const filePath = node_path_1.default.join(tmpDir, `${guid}.txt`);
36
- await index_1.pfs.write(filePath, payload);
37
- const { size } = node_fs_1.default.lstatSync(filePath);
38
- (0, node_assert_1.default)(payload.length === size);
39
- });
40
- (0, node_test_1.it)('Positive: Must rewrite content if file already exists', async () => {
41
- const payload = chance.paragraph();
42
- await index_1.pfs.write(node_path_1.default.join(tmpDir, 'tings.txt'), payload);
43
- const { size } = node_fs_1.default.lstatSync(node_path_1.default.join(tmpDir, 'tings.txt'));
44
- (0, node_assert_1.default)(payload.length === size);
45
- });
46
- (0, node_test_1.it)('Negative: Throw if resource is directory', async () => {
47
- const payload = chance.paragraph();
48
- await node_assert_1.default.rejects(async () => {
49
- await index_1.pfs.write(tmpDir, payload);
50
- });
51
- });
52
- (0, node_test_1.it)(`Negative: Unexpected option 'flag' returns Error`, async () => {
53
- const payload = chance.paragraph();
54
- await node_assert_1.default.rejects(async () => {
55
- await index_1.pfs.write(node_path_1.default.join(tmpDir, 'tings.txt'), payload, {
56
- flag: 'r'
57
- });
58
- });
59
- });
60
- (0, node_test_1.it)('[sync] Positive: Write contents even to a non-existent file', () => {
61
- const payload = chance.paragraph();
62
- const guid = chance.guid();
63
- const filePath = node_path_1.default.join(tmpDir, `${guid}.txt`);
64
- index_1.pfs.write(filePath, payload, {
65
- sync: true
66
- });
67
- const content = node_fs_1.default.readFileSync(filePath, 'utf8');
68
- (0, node_assert_1.default)(payload === content);
69
- });
70
- (0, node_test_1.it)('[sync] Negative: Throw if resource is directory', () => {
71
- const payload = chance.paragraph();
72
- node_assert_1.default.throws(() => {
73
- index_1.pfs.write(tmpDir, payload, {
74
- sync: true
75
- });
76
- });
77
- });
78
- (0, node_test_1.it)(`[sync] Negative: Unexpected option 'flag' returns Error`, () => {
79
- const payload = chance.paragraph();
80
- node_assert_1.default.throws(() => {
81
- index_1.pfs.write(node_path_1.default.join(tmpDir, 'tings.txt'), payload, {
82
- sync: true,
83
- flag: 'r'
84
- });
85
- });
86
- });
87
- itUnix('[sync] Positive: Umask should be applied with bit masking', () => {
88
- const guid = chance.guid();
89
- const filePath = node_path_1.default.join(tmpDir, `${guid}.txt`);
90
- index_1.pfs.write(filePath, 'x', {
91
- sync: true,
92
- umask: 0o111
93
- });
94
- const mode = node_fs_1.default.statSync(filePath).mode & 0o777;
95
- (0, node_assert_1.default)(mode === 0o666);
96
- });
97
- });