pwd-fs 3.5.4 → 3.5.5
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.
- package/dist/bitmask.d.ts +10 -0
- package/dist/bitmask.js +10 -0
- package/dist/powered-file-system/append.d.ts +10 -0
- package/dist/powered-file-system/append.js +10 -0
- package/dist/powered-file-system/chmod.d.ts +10 -0
- package/dist/powered-file-system/chmod.js +10 -0
- package/dist/powered-file-system/chown.d.ts +10 -0
- package/dist/powered-file-system/chown.js +10 -0
- package/dist/powered-file-system/copy.d.ts +10 -0
- package/dist/powered-file-system/copy.js +10 -0
- package/dist/powered-file-system/empty-dir.d.ts +10 -0
- package/dist/powered-file-system/empty-dir.js +10 -0
- package/dist/powered-file-system/mkdir.d.ts +10 -0
- package/dist/powered-file-system/mkdir.js +10 -0
- package/dist/powered-file-system/read.d.ts +10 -0
- package/dist/powered-file-system/read.js +10 -0
- package/dist/powered-file-system/readdir.d.ts +10 -0
- package/dist/powered-file-system/readdir.js +10 -0
- package/dist/powered-file-system/readlink.d.ts +10 -0
- package/dist/powered-file-system/readlink.js +10 -0
- package/dist/powered-file-system/realpath.d.ts +10 -0
- package/dist/powered-file-system/realpath.js +10 -0
- package/dist/powered-file-system/remove.d.ts +10 -0
- package/dist/powered-file-system/remove.js +10 -0
- package/dist/powered-file-system/rename.d.ts +10 -0
- package/dist/powered-file-system/rename.js +10 -0
- package/dist/powered-file-system/stat.d.ts +10 -0
- package/dist/powered-file-system/stat.js +10 -0
- package/dist/powered-file-system/symlink.d.ts +10 -0
- package/dist/powered-file-system/symlink.js +10 -0
- package/dist/powered-file-system/test.d.ts +10 -0
- package/dist/powered-file-system/test.js +10 -0
- package/dist/powered-file-system/write.d.ts +10 -0
- package/dist/powered-file-system/write.js +10 -0
- package/dist/powered-file-system.d.ts +10 -0
- package/dist/powered-file-system.js +10 -0
- package/dist/recurse-io-sync.d.ts +10 -0
- package/dist/recurse-io-sync.js +10 -0
- package/dist/recurse-io.d.ts +10 -0
- package/dist/recurse-io.js +10 -0
- package/package.json +8 -19
- package/readme.md +273 -426
- package/dist/bitmask.test.d.ts +0 -1
- package/dist/bitmask.test.js +0 -29
- package/dist/powered-file-system/append.test.d.ts +0 -1
- package/dist/powered-file-system/append.test.js +0 -47
- package/dist/powered-file-system/chmod.test.d.ts +0 -1
- package/dist/powered-file-system/chmod.test.js +0 -71
- package/dist/powered-file-system/chown.test.d.ts +0 -1
- package/dist/powered-file-system/chown.test.js +0 -82
- package/dist/powered-file-system/copy.test.d.ts +0 -1
- package/dist/powered-file-system/copy.test.js +0 -128
- package/dist/powered-file-system/empty-dir.test.d.ts +0 -1
- package/dist/powered-file-system/empty-dir.test.js +0 -61
- package/dist/powered-file-system/mkdir.test.d.ts +0 -1
- package/dist/powered-file-system/mkdir.test.js +0 -116
- package/dist/powered-file-system/read.test.d.ts +0 -1
- package/dist/powered-file-system/read.test.js +0 -75
- package/dist/powered-file-system/readdir.test.d.ts +0 -1
- package/dist/powered-file-system/readdir.test.js +0 -72
- package/dist/powered-file-system/readlink.test.d.ts +0 -1
- package/dist/powered-file-system/readlink.test.js +0 -44
- package/dist/powered-file-system/realpath.test.d.ts +0 -1
- package/dist/powered-file-system/realpath.test.js +0 -44
- package/dist/powered-file-system/remove.test.d.ts +0 -1
- package/dist/powered-file-system/remove.test.js +0 -78
- package/dist/powered-file-system/rename.test.d.ts +0 -1
- package/dist/powered-file-system/rename.test.js +0 -70
- package/dist/powered-file-system/stat.test.d.ts +0 -1
- package/dist/powered-file-system/stat.test.js +0 -79
- package/dist/powered-file-system/symlink.test.d.ts +0 -1
- package/dist/powered-file-system/symlink.test.js +0 -77
- package/dist/powered-file-system/test.test.d.ts +0 -1
- package/dist/powered-file-system/test.test.js +0 -76
- package/dist/powered-file-system/write.test.d.ts +0 -1
- package/dist/powered-file-system/write.test.js +0 -97
- package/dist/powered-file-system.test.d.ts +0 -1
- package/dist/powered-file-system.test.js +0 -46
- package/dist/suite.test.d.ts +0 -1
- package/dist/suite.test.js +0 -40
- package/dist/test-utils.d.ts +0 -18
- package/dist/test-utils.js +0 -72
package/dist/bitmask.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/bitmask.test.js
DELETED
|
@@ -1,29 +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_test_1 = require("node:test");
|
|
8
|
-
const index_1 = require("./index");
|
|
9
|
-
/**
|
|
10
|
-
* Covers normalization of permission masks exposed through the public entrypoint.
|
|
11
|
-
*/
|
|
12
|
-
(0, node_test_1.describe)('static bitmask(mode: number)', () => {
|
|
13
|
-
(0, node_test_1.it)('Positive: Calculate bitmask', () => {
|
|
14
|
-
(0, node_assert_1.default)((0, index_1.bitmask)(33024) === 0o400);
|
|
15
|
-
(0, node_assert_1.default)((0, index_1.bitmask)(33152) === 0o600);
|
|
16
|
-
(0, node_assert_1.default)((0, index_1.bitmask)(33216) === 0o700);
|
|
17
|
-
(0, node_assert_1.default)((0, index_1.bitmask)(32800) === 0o040);
|
|
18
|
-
(0, node_assert_1.default)((0, index_1.bitmask)(32816) === 0o060);
|
|
19
|
-
(0, node_assert_1.default)((0, index_1.bitmask)(32824) === 0o070);
|
|
20
|
-
(0, node_assert_1.default)((0, index_1.bitmask)(32772) === 0o004);
|
|
21
|
-
(0, node_assert_1.default)((0, index_1.bitmask)(32774) === 0o006);
|
|
22
|
-
(0, node_assert_1.default)((0, index_1.bitmask)(32775) === 0o007);
|
|
23
|
-
});
|
|
24
|
-
(0, node_test_1.it)(`Negative: Throw an exception if the argument is 'null' type`, () => {
|
|
25
|
-
node_assert_1.default.throws(() => {
|
|
26
|
-
(0, index_1.bitmask)(null);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,47 +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 the deprecated append helper in both async and sync modes.
|
|
15
|
-
*/
|
|
16
|
-
(0, node_test_1.describe)('append(src, data [, 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: 'hoodie'
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
(0, node_test_1.afterEach)(() => {
|
|
29
|
-
(0, test_utils_1.restore)(tmpDir);
|
|
30
|
-
});
|
|
31
|
-
(0, node_test_1.it)('Positive: Must append content to file', async () => {
|
|
32
|
-
const payload = chance.paragraph();
|
|
33
|
-
const filePath = node_path_1.default.join(tmpDir, 'tings.txt');
|
|
34
|
-
await index_1.pfs.append(filePath, payload);
|
|
35
|
-
const { size } = node_fs_1.default.statSync(filePath);
|
|
36
|
-
(0, node_assert_1.default)(payload.length + 6 === size);
|
|
37
|
-
});
|
|
38
|
-
(0, node_test_1.it)('[sync] Positive: Must append content to file', () => {
|
|
39
|
-
const payload = chance.paragraph();
|
|
40
|
-
const filePath = node_path_1.default.join(tmpDir, 'tings.txt');
|
|
41
|
-
index_1.pfs.append(filePath, payload, {
|
|
42
|
-
sync: true
|
|
43
|
-
});
|
|
44
|
-
const { size } = node_fs_1.default.statSync(filePath);
|
|
45
|
-
(0, node_assert_1.default)(payload.length + 6 === size);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,71 +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 recursive permission updates affect both directories and nested files.
|
|
14
|
-
*/
|
|
15
|
-
(0, node_test_1.describe)('chmod(src, mode [, 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
|
-
});
|
|
26
|
-
});
|
|
27
|
-
(0, node_test_1.afterEach)(() => {
|
|
28
|
-
(0, test_utils_1.restore)(tmpDir);
|
|
29
|
-
});
|
|
30
|
-
(0, node_test_1.it)('Positive: Changes directory and file permissions', async () => {
|
|
31
|
-
await index_1.pfs.chmod(tmpDir, 0o444);
|
|
32
|
-
const writable = index_1.pfs.test(node_path_1.default.join(tmpDir, 'tings.txt'), {
|
|
33
|
-
sync: true,
|
|
34
|
-
flag: 'w'
|
|
35
|
-
});
|
|
36
|
-
(0, node_assert_1.default)(writable === false);
|
|
37
|
-
});
|
|
38
|
-
(0, node_test_1.it)('Negative: Throw if not exists resource', async () => {
|
|
39
|
-
await node_assert_1.default.rejects(async () => {
|
|
40
|
-
await index_1.pfs.chmod('./non-existent-source', 0o744);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
(0, node_test_1.it)('[sync] Positive: Changes permissions of directory', () => {
|
|
44
|
-
index_1.pfs.chmod(tmpDir, 0o444, {
|
|
45
|
-
sync: true
|
|
46
|
-
});
|
|
47
|
-
const writable = index_1.pfs.test(node_path_1.default.join(tmpDir, 'tings.txt'), {
|
|
48
|
-
sync: true,
|
|
49
|
-
flag: 'w'
|
|
50
|
-
});
|
|
51
|
-
(0, node_assert_1.default)(writable === false);
|
|
52
|
-
});
|
|
53
|
-
(0, node_test_1.it)('[sync] Positive: Changes file permissions', () => {
|
|
54
|
-
index_1.pfs.chmod(node_path_1.default.join(tmpDir, 'tings.txt'), 0o444, {
|
|
55
|
-
sync: true
|
|
56
|
-
});
|
|
57
|
-
const writable = index_1.pfs.test(node_path_1.default.join(tmpDir, 'tings.txt'), {
|
|
58
|
-
sync: true,
|
|
59
|
-
flag: 'w'
|
|
60
|
-
});
|
|
61
|
-
(0, node_assert_1.default)(writable === 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.chmod(`./${guid}`, 0o744, {
|
|
67
|
-
sync: true
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
@@ -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 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
|
-
* Validates ownership changes while preserving path validation semantics.
|
|
15
|
-
*/
|
|
16
|
-
(0, node_test_1.describe)('chown(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: Changes the permissions of a file', async () => {
|
|
33
|
-
const filePath = node_path_1.default.join(tmpDir, 'tings.txt');
|
|
34
|
-
const { uid, gid } = node_fs_1.default.statSync(filePath);
|
|
35
|
-
await index_1.pfs.chown(filePath, { uid, gid });
|
|
36
|
-
(0, node_assert_1.default)(node_fs_1.default.existsSync(filePath));
|
|
37
|
-
});
|
|
38
|
-
(0, node_test_1.it)('Positive: Changes the permissions of a directory', async () => {
|
|
39
|
-
const dirPath = node_path_1.default.join(tmpDir, 'digest');
|
|
40
|
-
const { uid, gid } = node_fs_1.default.statSync(dirPath);
|
|
41
|
-
await index_1.pfs.chown(dirPath, { uid, gid });
|
|
42
|
-
(0, node_assert_1.default)(node_fs_1.default.existsSync(dirPath));
|
|
43
|
-
});
|
|
44
|
-
(0, node_test_1.it)('Negative: To a non-existent resource to return an Error', async () => {
|
|
45
|
-
const guid = chance.guid();
|
|
46
|
-
const { uid, gid } = node_fs_1.default.statSync(node_path_1.default.join(tmpDir, 'tings.txt'));
|
|
47
|
-
await node_assert_1.default.rejects(async () => {
|
|
48
|
-
await index_1.pfs.chown(node_path_1.default.join(tmpDir, guid), { uid, gid });
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
(0, node_test_1.it)('[sync] Positive: Changes the permissions of a file', () => {
|
|
52
|
-
const filePath = node_path_1.default.join(tmpDir, 'tings.txt');
|
|
53
|
-
const { uid, gid } = node_fs_1.default.statSync(filePath);
|
|
54
|
-
index_1.pfs.chown(filePath, {
|
|
55
|
-
sync: true,
|
|
56
|
-
uid,
|
|
57
|
-
gid
|
|
58
|
-
});
|
|
59
|
-
(0, node_assert_1.default)(node_fs_1.default.existsSync(filePath));
|
|
60
|
-
});
|
|
61
|
-
(0, node_test_1.it)('[sync] Positive: Changes the permissions of a directory', () => {
|
|
62
|
-
const dirPath = node_path_1.default.join(tmpDir, 'digest');
|
|
63
|
-
const { uid, gid } = node_fs_1.default.statSync(dirPath);
|
|
64
|
-
index_1.pfs.chown(dirPath, {
|
|
65
|
-
sync: true,
|
|
66
|
-
uid,
|
|
67
|
-
gid
|
|
68
|
-
});
|
|
69
|
-
(0, node_assert_1.default)(node_fs_1.default.existsSync(dirPath));
|
|
70
|
-
});
|
|
71
|
-
(0, node_test_1.it)('[sync] Negative: To a non-existent resource to return an Error', () => {
|
|
72
|
-
const guid = chance.guid();
|
|
73
|
-
const { uid, gid } = node_fs_1.default.statSync(node_path_1.default.join(tmpDir, 'tings.txt'));
|
|
74
|
-
node_assert_1.default.throws(() => {
|
|
75
|
-
index_1.pfs.chown(node_path_1.default.join(tmpDir, guid), {
|
|
76
|
-
sync: true,
|
|
77
|
-
uid,
|
|
78
|
-
gid
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,128 +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 and directory copy behavior, including collision handling.
|
|
15
|
-
*/
|
|
16
|
-
(0, node_test_1.describe)('copy(src, dir [, 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: Copying a item file', async () => {
|
|
33
|
-
await index_1.pfs.copy(node_path_1.default.join(tmpDir, 'tings.txt'), node_path_1.default.join(tmpDir, 'digest'));
|
|
34
|
-
const exist = node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'digest', 'tings.txt'));
|
|
35
|
-
(0, node_assert_1.default)(exist);
|
|
36
|
-
});
|
|
37
|
-
(0, node_test_1.it)('Positive: Recursive copying a directory', async () => {
|
|
38
|
-
await index_1.pfs.copy(node_path_1.default.resolve('./src'), tmpDir);
|
|
39
|
-
const exist = node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'src'));
|
|
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.copy(node_path_1.default.join(tmpDir, guid), tmpDir);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
(0, node_test_1.it)('Negative: An attempt to copy to an existing resource should return an Error', async () => {
|
|
49
|
-
await node_assert_1.default.rejects(async () => {
|
|
50
|
-
await index_1.pfs.copy(tmpDir, node_path_1.default.dirname(tmpDir));
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
(0, node_test_1.it)('Positive: Overwrite should replace an existing target file', async () => {
|
|
54
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(tmpDir, 'digest', 'tings.txt'), 'old');
|
|
55
|
-
await index_1.pfs.copy(node_path_1.default.join(tmpDir, 'tings.txt'), node_path_1.default.join(tmpDir, 'digest'), {
|
|
56
|
-
overwrite: true
|
|
57
|
-
});
|
|
58
|
-
const content = node_fs_1.default.readFileSync(node_path_1.default.join(tmpDir, 'digest', 'tings.txt'), 'utf8');
|
|
59
|
-
(0, node_assert_1.default)(content !== 'old');
|
|
60
|
-
});
|
|
61
|
-
(0, node_test_1.it)('Positive: Filter should skip matching entries', async () => {
|
|
62
|
-
const destRoot = (0, test_utils_1.createTmpDir)();
|
|
63
|
-
try {
|
|
64
|
-
await index_1.pfs.copy(tmpDir, destRoot, {
|
|
65
|
-
overwrite: true,
|
|
66
|
-
filter: (src) => node_path_1.default.basename(src) !== 'tings.txt'
|
|
67
|
-
});
|
|
68
|
-
(0, node_assert_1.default)(node_fs_1.default.existsSync(node_path_1.default.join(destRoot, node_path_1.default.basename(tmpDir), 'digest')));
|
|
69
|
-
(0, node_assert_1.default)(node_fs_1.default.existsSync(node_path_1.default.join(destRoot, node_path_1.default.basename(tmpDir), 'tings.txt')) === false);
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
(0, test_utils_1.restore)(destRoot);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
(0, node_test_1.it)('[sync] Positive: Copying a file', () => {
|
|
76
|
-
index_1.pfs.copy(node_path_1.default.join(tmpDir, 'tings.txt'), node_path_1.default.join(tmpDir, 'digest'), {
|
|
77
|
-
sync: true
|
|
78
|
-
});
|
|
79
|
-
const exist = node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'digest', 'tings.txt'));
|
|
80
|
-
(0, node_assert_1.default)(exist);
|
|
81
|
-
});
|
|
82
|
-
(0, node_test_1.it)('[sync] Positive: Recursive copying a directory', () => {
|
|
83
|
-
index_1.pfs.copy(node_path_1.default.resolve('./src'), tmpDir, {
|
|
84
|
-
sync: true
|
|
85
|
-
});
|
|
86
|
-
const exist = node_fs_1.default.existsSync(node_path_1.default.join(tmpDir, 'src'));
|
|
87
|
-
(0, node_assert_1.default)(exist);
|
|
88
|
-
});
|
|
89
|
-
(0, node_test_1.it)('[sync] Negative: Throw if not exists resource', () => {
|
|
90
|
-
const guid = chance.guid();
|
|
91
|
-
node_assert_1.default.throws(() => {
|
|
92
|
-
index_1.pfs.copy(node_path_1.default.join(tmpDir, guid), tmpDir, {
|
|
93
|
-
sync: true
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
(0, node_test_1.it)('[sync] Negative: An attempt to copy to an existing resource should return an Error', () => {
|
|
98
|
-
node_assert_1.default.throws(() => {
|
|
99
|
-
index_1.pfs.copy(tmpDir, node_path_1.default.dirname(tmpDir), {
|
|
100
|
-
sync: true
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
(0, node_test_1.it)('[sync] Positive: Overwrite should replace an existing target file', () => {
|
|
105
|
-
node_fs_1.default.writeFileSync(node_path_1.default.join(tmpDir, 'digest', 'tings.txt'), 'old');
|
|
106
|
-
index_1.pfs.copy(node_path_1.default.join(tmpDir, 'tings.txt'), node_path_1.default.join(tmpDir, 'digest'), {
|
|
107
|
-
sync: true,
|
|
108
|
-
overwrite: true
|
|
109
|
-
});
|
|
110
|
-
const content = node_fs_1.default.readFileSync(node_path_1.default.join(tmpDir, 'digest', 'tings.txt'), 'utf8');
|
|
111
|
-
(0, node_assert_1.default)(content !== 'old');
|
|
112
|
-
});
|
|
113
|
-
(0, node_test_1.it)('[sync] Positive: Filter should skip matching entries', () => {
|
|
114
|
-
const destRoot = (0, test_utils_1.createTmpDir)();
|
|
115
|
-
try {
|
|
116
|
-
index_1.pfs.copy(tmpDir, destRoot, {
|
|
117
|
-
sync: true,
|
|
118
|
-
overwrite: true,
|
|
119
|
-
filter: (src) => node_path_1.default.basename(src) !== 'tings.txt'
|
|
120
|
-
});
|
|
121
|
-
(0, node_assert_1.default)(node_fs_1.default.existsSync(node_path_1.default.join(destRoot, node_path_1.default.basename(tmpDir), 'digest')));
|
|
122
|
-
(0, node_assert_1.default)(node_fs_1.default.existsSync(node_path_1.default.join(destRoot, node_path_1.default.basename(tmpDir), 'tings.txt')) === false);
|
|
123
|
-
}
|
|
124
|
-
finally {
|
|
125
|
-
(0, test_utils_1.restore)(destRoot);
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,61 +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 directory cleanup while preserving the directory itself.
|
|
15
|
-
*/
|
|
16
|
-
(0, node_test_1.describe)('emptyDir(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, 'digest', 'nested.txt')]: {
|
|
28
|
-
type: 'file',
|
|
29
|
-
data: chance.string()
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
(0, test_utils_1.fmock)(frame);
|
|
33
|
-
});
|
|
34
|
-
(0, node_test_1.afterEach)(() => {
|
|
35
|
-
(0, test_utils_1.restore)(tmpDir);
|
|
36
|
-
});
|
|
37
|
-
(0, node_test_1.it)('Positive: Removes all directory contents but preserves the directory', async () => {
|
|
38
|
-
await index_1.pfs.emptyDir(tmpDir);
|
|
39
|
-
(0, node_assert_1.default)(node_fs_1.default.existsSync(tmpDir));
|
|
40
|
-
node_assert_1.default.deepStrictEqual(node_fs_1.default.readdirSync(tmpDir), []);
|
|
41
|
-
});
|
|
42
|
-
(0, node_test_1.it)('Negative: Throw if resource is not directory', async () => {
|
|
43
|
-
await node_assert_1.default.rejects(async () => {
|
|
44
|
-
await index_1.pfs.emptyDir(node_path_1.default.join(tmpDir, 'tings.txt'));
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
(0, node_test_1.it)('[sync] Positive: Removes all directory contents but preserves the directory', () => {
|
|
48
|
-
index_1.pfs.emptyDir(tmpDir, {
|
|
49
|
-
sync: true
|
|
50
|
-
});
|
|
51
|
-
(0, node_assert_1.default)(node_fs_1.default.existsSync(tmpDir));
|
|
52
|
-
node_assert_1.default.deepStrictEqual(node_fs_1.default.readdirSync(tmpDir), []);
|
|
53
|
-
});
|
|
54
|
-
(0, node_test_1.it)('[sync] Negative: Throw if resource is not directory', () => {
|
|
55
|
-
node_assert_1.default.throws(() => {
|
|
56
|
-
index_1.pfs.emptyDir(node_path_1.default.join(tmpDir, 'tings.txt'), {
|
|
57
|
-
sync: true
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,116 +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_os_1 = __importDefault(require("node:os"));
|
|
9
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
-
const chance_1 = __importDefault(require("chance"));
|
|
11
|
-
const node_test_1 = require("node:test");
|
|
12
|
-
const index_1 = require("../index");
|
|
13
|
-
const test_utils_1 = require("../test-utils");
|
|
14
|
-
/**
|
|
15
|
-
* Verifies recursive directory creation for absolute and instance-relative roots.
|
|
16
|
-
*/
|
|
17
|
-
(0, node_test_1.describe)('mkdir(src [, options])', () => {
|
|
18
|
-
const chance = new chance_1.default();
|
|
19
|
-
let tmpDir = '';
|
|
20
|
-
let pfs = new index_1.PoweredFileSystem();
|
|
21
|
-
(0, node_test_1.beforeEach)(() => {
|
|
22
|
-
tmpDir = (0, test_utils_1.createTmpDir)();
|
|
23
|
-
pfs = new index_1.PoweredFileSystem();
|
|
24
|
-
(0, test_utils_1.fmock)({
|
|
25
|
-
[node_path_1.default.join(tmpDir, 'tings.txt')]: {
|
|
26
|
-
type: 'file',
|
|
27
|
-
data: chance.string()
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
(0, node_test_1.afterEach)(() => {
|
|
32
|
-
(0, test_utils_1.restore)(tmpDir);
|
|
33
|
-
});
|
|
34
|
-
(0, node_test_1.it)('Positive: Create directories in the working directory', async () => {
|
|
35
|
-
const guid = chance.guid();
|
|
36
|
-
const target = node_path_1.default.join(tmpDir, guid);
|
|
37
|
-
await pfs.mkdir(target);
|
|
38
|
-
const exist = node_fs_1.default.existsSync(target);
|
|
39
|
-
(0, node_assert_1.default)(exist);
|
|
40
|
-
});
|
|
41
|
-
(0, node_test_1.it)('Positive: Make current directory', async () => {
|
|
42
|
-
const guid = chance.guid();
|
|
43
|
-
const target = node_path_1.default.join(tmpDir, guid);
|
|
44
|
-
const nextPfs = new index_1.PoweredFileSystem(target);
|
|
45
|
-
await nextPfs.mkdir('.');
|
|
46
|
-
const exist = node_fs_1.default.existsSync(target);
|
|
47
|
-
(0, node_assert_1.default)(exist);
|
|
48
|
-
});
|
|
49
|
-
(0, node_test_1.it)('Positive: Should work fine with the existing directory', async () => {
|
|
50
|
-
const guid = chance.guid();
|
|
51
|
-
const target = node_path_1.default.join(tmpDir, guid);
|
|
52
|
-
for (let i = 2; i; i--) {
|
|
53
|
-
await pfs.mkdir(target);
|
|
54
|
-
}
|
|
55
|
-
const exist = node_fs_1.default.existsSync(target);
|
|
56
|
-
(0, node_assert_1.default)(exist);
|
|
57
|
-
});
|
|
58
|
-
(0, node_test_1.it)('Negative: Throw an exception if trying to create a directory in file', async () => {
|
|
59
|
-
const guid = chance.guid();
|
|
60
|
-
await node_assert_1.default.rejects(async () => {
|
|
61
|
-
await pfs.mkdir(node_path_1.default.join(tmpDir, 'tings.txt', guid));
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
(0, node_test_1.it)('[sync] Positive: Create directories in the working directory', () => {
|
|
65
|
-
const guid = chance.guid();
|
|
66
|
-
const target = node_path_1.default.join(tmpDir, guid);
|
|
67
|
-
pfs.mkdir(target, {
|
|
68
|
-
sync: true
|
|
69
|
-
});
|
|
70
|
-
const exist = node_fs_1.default.existsSync(target);
|
|
71
|
-
(0, node_assert_1.default)(exist);
|
|
72
|
-
});
|
|
73
|
-
(0, node_test_1.it)('[sync] Positive: Make current directory', () => {
|
|
74
|
-
const guid = chance.guid();
|
|
75
|
-
const target = node_path_1.default.join(tmpDir, guid);
|
|
76
|
-
const nextPfs = new index_1.PoweredFileSystem(target);
|
|
77
|
-
nextPfs.mkdir('.', {
|
|
78
|
-
sync: true
|
|
79
|
-
});
|
|
80
|
-
const exist = node_fs_1.default.existsSync(target);
|
|
81
|
-
(0, node_assert_1.default)(exist);
|
|
82
|
-
});
|
|
83
|
-
(0, node_test_1.it)('[sync] Positive: Should work fine with the existing directory', () => {
|
|
84
|
-
const guid = chance.guid();
|
|
85
|
-
const target = node_path_1.default.join(tmpDir, guid);
|
|
86
|
-
for (let i = 2; i; i--) {
|
|
87
|
-
pfs.mkdir(target, {
|
|
88
|
-
sync: true
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
const exist = node_fs_1.default.existsSync(target);
|
|
92
|
-
(0, node_assert_1.default)(exist);
|
|
93
|
-
});
|
|
94
|
-
(0, node_test_1.it)('[sync] Negative: Throw an exception if trying to create a directory in file', () => {
|
|
95
|
-
const guid = chance.guid();
|
|
96
|
-
node_assert_1.default.throws(() => {
|
|
97
|
-
pfs.mkdir(node_path_1.default.join(tmpDir, 'tings.txt', guid), {
|
|
98
|
-
sync: true
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
(0, node_test_1.it)('[sync] Positive: Absolute pwd should create the target directory itself', () => {
|
|
103
|
-
const guid = chance.guid();
|
|
104
|
-
const target = node_path_1.default.join(node_os_1.default.tmpdir(), guid);
|
|
105
|
-
const nextPfs = new index_1.PoweredFileSystem(target);
|
|
106
|
-
try {
|
|
107
|
-
nextPfs.mkdir('.', {
|
|
108
|
-
sync: true
|
|
109
|
-
});
|
|
110
|
-
(0, node_assert_1.default)(node_fs_1.default.existsSync(target));
|
|
111
|
-
}
|
|
112
|
-
finally {
|
|
113
|
-
node_fs_1.default.rmSync(target, { recursive: true, force: true });
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,75 +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
|
-
* Covers text and binary reads together with failure cases.
|
|
14
|
-
*/
|
|
15
|
-
(0, node_test_1.describe)('read(src [, options])', () => {
|
|
16
|
-
const chance = new chance_1.default();
|
|
17
|
-
let sentences = 0;
|
|
18
|
-
let tmpDir = '';
|
|
19
|
-
(0, node_test_1.beforeEach)(() => {
|
|
20
|
-
tmpDir = (0, test_utils_1.createTmpDir)();
|
|
21
|
-
const tingsContent = chance.paragraph();
|
|
22
|
-
sentences = tingsContent.length;
|
|
23
|
-
(0, test_utils_1.fmock)({
|
|
24
|
-
[node_path_1.default.join(tmpDir, 'tings.txt')]: {
|
|
25
|
-
type: 'file',
|
|
26
|
-
data: tingsContent
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
(0, node_test_1.afterEach)(() => {
|
|
31
|
-
(0, test_utils_1.restore)(tmpDir);
|
|
32
|
-
});
|
|
33
|
-
(0, node_test_1.it)('Positive: Must read content of file; String type by default', async () => {
|
|
34
|
-
const { length } = await index_1.pfs.read(node_path_1.default.join(tmpDir, 'tings.txt'));
|
|
35
|
-
(0, node_assert_1.default)(length === sentences);
|
|
36
|
-
});
|
|
37
|
-
(0, node_test_1.it)('Positive: Must read Buffer content of file when encoding is null', async () => {
|
|
38
|
-
const buffer = await index_1.pfs.read(node_path_1.default.join(tmpDir, 'tings.txt'), {
|
|
39
|
-
encoding: null
|
|
40
|
-
});
|
|
41
|
-
(0, node_assert_1.default)(buffer instanceof Buffer);
|
|
42
|
-
});
|
|
43
|
-
(0, node_test_1.it)('Negative: Throw if resource is not file', async () => {
|
|
44
|
-
await node_assert_1.default.rejects(async () => {
|
|
45
|
-
await index_1.pfs.read(tmpDir);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
(0, node_test_1.it)('Negative: Throw if not exists resource', async () => {
|
|
49
|
-
const guid = chance.guid();
|
|
50
|
-
await node_assert_1.default.rejects(async () => {
|
|
51
|
-
await index_1.pfs.read(node_path_1.default.join(tmpDir, guid));
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
(0, node_test_1.it)('[sync] Positive: Must read content of file; String type by default', () => {
|
|
55
|
-
const { length } = index_1.pfs.read(node_path_1.default.join(tmpDir, 'tings.txt'), {
|
|
56
|
-
sync: true
|
|
57
|
-
});
|
|
58
|
-
(0, node_assert_1.default)(length === sentences);
|
|
59
|
-
});
|
|
60
|
-
(0, node_test_1.it)('[sync] Positive: Must read Buffer content of file when encoding is null', () => {
|
|
61
|
-
const buf = index_1.pfs.read(node_path_1.default.join(tmpDir, 'tings.txt'), {
|
|
62
|
-
sync: true,
|
|
63
|
-
encoding: null
|
|
64
|
-
});
|
|
65
|
-
(0, node_assert_1.default)(buf instanceof Buffer);
|
|
66
|
-
});
|
|
67
|
-
(0, node_test_1.it)('[sync] Negative: Throw if not exists resource', () => {
|
|
68
|
-
const guid = chance.guid();
|
|
69
|
-
node_assert_1.default.throws(() => {
|
|
70
|
-
index_1.pfs.read(node_path_1.default.join(tmpDir, guid), {
|
|
71
|
-
sync: true
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|