pwd-fs 3.2.0 → 3.2.2
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/{lib → dist}/src/powered-file-system.d.ts +4 -4
- package/{lib → dist}/src/powered-file-system.js +4 -4
- package/package.json +4 -4
- package/src/powered-file-system.ts +17 -32
- package/test/read.spec.ts +4 -4
- package/tsconfig.json +2 -7
- package/lib/test/__fmock.d.ts +0 -5
- package/lib/test/__fmock.js +0 -40
- package/lib/test/append.spec.d.ts +0 -1
- package/lib/test/append.spec.js +0 -58
- package/lib/test/bitmask.spec.d.ts +0 -1
- package/lib/test/bitmask.spec.js +0 -26
- package/lib/test/chmod.spec.d.ts +0 -1
- package/lib/test/chmod.spec.js +0 -62
- package/lib/test/chown.spec.d.ts +0 -1
- package/lib/test/chown.spec.js +0 -74
- package/lib/test/constructor.spec.d.ts +0 -1
- package/lib/test/constructor.spec.js +0 -17
- package/lib/test/copy.spec.d.ts +0 -1
- package/lib/test/copy.spec.js +0 -80
- package/lib/test/mkdir.spec.d.ts +0 -1
- package/lib/test/mkdir.spec.js +0 -90
- package/lib/test/read.spec.d.ts +0 -1
- package/lib/test/read.spec.js +0 -73
- package/lib/test/readdir.spec.d.ts +0 -1
- package/lib/test/readdir.spec.js +0 -70
- package/lib/test/remove.spec.d.ts +0 -1
- package/lib/test/remove.spec.js +0 -63
- package/lib/test/rename.spec.d.ts +0 -1
- package/lib/test/rename.spec.js +0 -66
- package/lib/test/stat.spec.d.ts +0 -1
- package/lib/test/stat.spec.js +0 -76
- package/lib/test/symlink.spec.d.ts +0 -1
- package/lib/test/symlink.spec.js +0 -74
- package/lib/test/test.spec.d.ts +0 -1
- package/lib/test/test.spec.js +0 -60
- package/lib/test/write.spec.d.ts +0 -1
- package/lib/test/write.spec.js +0 -82
- /package/{lib → dist}/src/bitmask.d.ts +0 -0
- /package/{lib → dist}/src/bitmask.js +0 -0
- /package/{lib → dist}/src/index.d.ts +0 -0
- /package/{lib → dist}/src/index.js +0 -0
- /package/{lib → dist}/src/recurse-io-sync.d.ts +0 -0
- /package/{lib → dist}/src/recurse-io-sync.js +0 -0
- /package/{lib → dist}/src/recurse-io.d.ts +0 -0
- /package/{lib → dist}/src/recurse-io.js +0 -0
|
@@ -76,14 +76,14 @@ export declare class PoweredFileSystem {
|
|
|
76
76
|
}): Promise<void>;
|
|
77
77
|
read(src: string, options: {
|
|
78
78
|
sync: true;
|
|
79
|
-
encoding
|
|
79
|
+
encoding: null;
|
|
80
80
|
flag?: Flag;
|
|
81
|
-
}):
|
|
81
|
+
}): Buffer;
|
|
82
82
|
read(src: string, options: {
|
|
83
83
|
sync: true;
|
|
84
|
-
encoding?:
|
|
84
|
+
encoding?: BufferEncoding;
|
|
85
85
|
flag?: Flag;
|
|
86
|
-
}):
|
|
86
|
+
}): string;
|
|
87
87
|
read(src: string, options: {
|
|
88
88
|
sync?: false;
|
|
89
89
|
encoding: null;
|
|
@@ -162,10 +162,13 @@ class PoweredFileSystem {
|
|
|
162
162
|
read(src, { sync = false, encoding = 'utf8', flag = 'r' } = {}) {
|
|
163
163
|
src = this.resolve(src);
|
|
164
164
|
if (sync) {
|
|
165
|
-
|
|
165
|
+
const content = node_fs_1.default.readFileSync(src, {
|
|
166
166
|
encoding,
|
|
167
167
|
flag
|
|
168
168
|
});
|
|
169
|
+
return encoding === null
|
|
170
|
+
? Buffer.from(content)
|
|
171
|
+
: content;
|
|
169
172
|
}
|
|
170
173
|
return new Promise((resolve, reject) => {
|
|
171
174
|
node_fs_1.default.readFile(src, {
|
|
@@ -202,9 +205,6 @@ class PoweredFileSystem {
|
|
|
202
205
|
});
|
|
203
206
|
});
|
|
204
207
|
}
|
|
205
|
-
/**
|
|
206
|
-
* @deprecated The method should not be used
|
|
207
|
-
*/
|
|
208
208
|
append(src, data, { sync = false, encoding = 'utf8', umask = 0o000, flag = 'a' } = {}) {
|
|
209
209
|
src = this.resolve(src);
|
|
210
210
|
const mode = 0o666 - umask;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pwd-fs",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "Extend the file system the capabilities of declaring the present working directory and recursive execution",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"umask",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": ">=13.2.0"
|
|
31
31
|
},
|
|
32
|
-
"main": "./
|
|
33
|
-
"types": "./
|
|
32
|
+
"main": "./dist/src/index.js",
|
|
33
|
+
"types": "./dist/src/index.d.ts",
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsc",
|
|
36
|
-
"test": "mocha ./
|
|
36
|
+
"test": "mocha ./dist/test"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/chance": "^1.1.6",
|
|
@@ -92,13 +92,9 @@ export class PoweredFileSystem {
|
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
chmod(src: string, mode: number, options: {
|
|
96
|
-
sync: true
|
|
97
|
-
}): void;
|
|
95
|
+
chmod(src: string, mode: number, options: { sync: true }): void;
|
|
98
96
|
|
|
99
|
-
chmod(src: string, mode: number, options?: {
|
|
100
|
-
sync?: false
|
|
101
|
-
}): Promise<void>;
|
|
97
|
+
chmod(src: string, mode: number, options?: { sync?: false }): Promise<void>;
|
|
102
98
|
|
|
103
99
|
chmod(src: string, mode: number, { sync = false }: { sync?: boolean } = {}) {
|
|
104
100
|
src = this.resolve(src);
|
|
@@ -148,13 +144,9 @@ export class PoweredFileSystem {
|
|
|
148
144
|
});
|
|
149
145
|
}
|
|
150
146
|
|
|
151
|
-
symlink(src: string, use: string, options: {
|
|
152
|
-
sync: true
|
|
153
|
-
}): void;
|
|
147
|
+
symlink(src: string, use: string, options: { sync: true }): void;
|
|
154
148
|
|
|
155
|
-
symlink(src: string, use: string, options?: {
|
|
156
|
-
sync?: false
|
|
157
|
-
}): Promise<void>;
|
|
149
|
+
symlink(src: string, use: string, options?: { sync?: false }): Promise<void>;
|
|
158
150
|
|
|
159
151
|
symlink(src: string, use: string, { sync = false }: { sync?: boolean } = {}) {
|
|
160
152
|
src = this.resolve(src);
|
|
@@ -207,13 +199,9 @@ export class PoweredFileSystem {
|
|
|
207
199
|
});
|
|
208
200
|
}
|
|
209
201
|
|
|
210
|
-
rename(src: string, use: string, options: {
|
|
211
|
-
sync: true
|
|
212
|
-
}): void;
|
|
202
|
+
rename(src: string, use: string, options: { sync: true }): void;
|
|
213
203
|
|
|
214
|
-
rename(src: string, use: string, options?: {
|
|
215
|
-
sync?: false
|
|
216
|
-
}): Promise<void>;
|
|
204
|
+
rename(src: string, use: string, options?: { sync?: false }): Promise<void>;
|
|
217
205
|
|
|
218
206
|
rename(src: string, use: string, { sync = false }: { sync?: boolean } = {}) {
|
|
219
207
|
src = this.resolve(src);
|
|
@@ -234,13 +222,9 @@ export class PoweredFileSystem {
|
|
|
234
222
|
});
|
|
235
223
|
}
|
|
236
224
|
|
|
237
|
-
remove(src: string, options: {
|
|
238
|
-
sync: true
|
|
239
|
-
}): void;
|
|
225
|
+
remove(src: string, options: { sync: true }): void;
|
|
240
226
|
|
|
241
|
-
remove(src: string, options?: {
|
|
242
|
-
sync?: false
|
|
243
|
-
}): Promise<void>;
|
|
227
|
+
remove(src: string, options?: { sync?: false }): Promise<void>;
|
|
244
228
|
|
|
245
229
|
remove(src: string, { sync = false }: { sync?: boolean } = {}) {
|
|
246
230
|
src = this.resolve(src);
|
|
@@ -268,15 +252,15 @@ export class PoweredFileSystem {
|
|
|
268
252
|
|
|
269
253
|
read(src: string, options: {
|
|
270
254
|
sync: true,
|
|
271
|
-
encoding
|
|
255
|
+
encoding: null,
|
|
272
256
|
flag?: Flag
|
|
273
|
-
}):
|
|
257
|
+
}): Buffer;
|
|
274
258
|
|
|
275
259
|
read(src: string, options: {
|
|
276
260
|
sync: true,
|
|
277
|
-
encoding?:
|
|
261
|
+
encoding?: BufferEncoding,
|
|
278
262
|
flag?: Flag
|
|
279
|
-
}):
|
|
263
|
+
}): string;
|
|
280
264
|
|
|
281
265
|
read(src: string, options: {
|
|
282
266
|
sync?: false,
|
|
@@ -298,10 +282,14 @@ export class PoweredFileSystem {
|
|
|
298
282
|
src = this.resolve(src);
|
|
299
283
|
|
|
300
284
|
if (sync) {
|
|
301
|
-
|
|
285
|
+
const content = fs.readFileSync(src, {
|
|
302
286
|
encoding,
|
|
303
287
|
flag
|
|
304
288
|
});
|
|
289
|
+
|
|
290
|
+
return encoding === null
|
|
291
|
+
? Buffer.from(content)
|
|
292
|
+
: content;
|
|
305
293
|
}
|
|
306
294
|
|
|
307
295
|
return new Promise((resolve, reject) => {
|
|
@@ -421,9 +409,6 @@ export class PoweredFileSystem {
|
|
|
421
409
|
flag?: Flag
|
|
422
410
|
}): Promise<void>;
|
|
423
411
|
|
|
424
|
-
/**
|
|
425
|
-
* @deprecated The method should not be used
|
|
426
|
-
*/
|
|
427
412
|
append(src: string, data: Buffer | string, { sync = false, encoding = 'utf8', umask = 0o000, flag = 'a' }: {
|
|
428
413
|
sync?: boolean,
|
|
429
414
|
encoding?: BufferEncoding | null,
|
package/test/read.spec.ts
CHANGED
|
@@ -70,12 +70,12 @@ describe('read(src [, options])', () => {
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
it('[sync] Positive: Must read Buffer content of file when encoding is null', () => {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
const buf = pfs.read('./tmpdir/tings.txt', {
|
|
74
|
+
sync: true,
|
|
75
|
+
encoding: null
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
assert(
|
|
78
|
+
assert(buf instanceof Buffer);
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
|
package/tsconfig.json
CHANGED
|
@@ -3,17 +3,12 @@
|
|
|
3
3
|
"lib": [
|
|
4
4
|
"es2022"
|
|
5
5
|
],
|
|
6
|
-
"module": "
|
|
6
|
+
"module": "commonjs",
|
|
7
7
|
"target": "es2022",
|
|
8
8
|
"moduleResolution": "node",
|
|
9
9
|
"resolveJsonModule": true,
|
|
10
10
|
"esModuleInterop": true,
|
|
11
|
-
"allowSyntheticDefaultImports": true,
|
|
12
|
-
"strict": true,
|
|
13
|
-
"useUnknownInCatchVariables": false,
|
|
14
11
|
"declaration": true,
|
|
15
|
-
"
|
|
16
|
-
"noUnusedLocals": false,
|
|
17
|
-
"outDir": "lib"
|
|
12
|
+
"outDir": "./dist"
|
|
18
13
|
}
|
|
19
14
|
}
|
package/lib/test/__fmock.d.ts
DELETED
package/lib/test/__fmock.js
DELETED
|
@@ -1,40 +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
|
-
exports.restore = exports.fmock = void 0;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
function fmock(frame) {
|
|
10
|
-
for (const src of Object.keys(frame)) {
|
|
11
|
-
const { dir } = node_path_1.default.parse(src);
|
|
12
|
-
const value = frame[src];
|
|
13
|
-
node_fs_1.default.mkdirSync(dir, { recursive: true });
|
|
14
|
-
if (value.type === 'directory') {
|
|
15
|
-
node_fs_1.default.mkdirSync(src);
|
|
16
|
-
}
|
|
17
|
-
if (value.type === 'file') {
|
|
18
|
-
node_fs_1.default.writeFileSync(src, value.data);
|
|
19
|
-
}
|
|
20
|
-
if (value.type === 'symlink') {
|
|
21
|
-
node_fs_1.default.symlinkSync(value.target, src);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.fmock = fmock;
|
|
26
|
-
function restore(tmpDir) {
|
|
27
|
-
const removeRecursive = (src) => {
|
|
28
|
-
if (node_fs_1.default.existsSync(src)) {
|
|
29
|
-
node_fs_1.default.readdirSync(src).forEach((item) => {
|
|
30
|
-
const curl = `${src}/${item}`;
|
|
31
|
-
node_fs_1.default.lstatSync(curl).isDirectory()
|
|
32
|
-
? removeRecursive(curl)
|
|
33
|
-
: node_fs_1.default.unlinkSync(curl);
|
|
34
|
-
});
|
|
35
|
-
node_fs_1.default.rmdirSync(src);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
removeRecursive(tmpDir);
|
|
39
|
-
}
|
|
40
|
-
exports.restore = restore;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/test/append.spec.js
DELETED
|
@@ -1,58 +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('append(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: 'hoodie'
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
afterEach(() => {
|
|
23
|
-
(0, __fmock_1.restore)('./tmpdir');
|
|
24
|
-
});
|
|
25
|
-
it('Positive: Must append content to file', async () => {
|
|
26
|
-
const payload = chance.paragraph();
|
|
27
|
-
await src_1.pfs.append('./tmpdir/tings.txt', payload);
|
|
28
|
-
const { size } = node_fs_1.default.statSync('./tmpdir/tings.txt');
|
|
29
|
-
(0, node_assert_1.default)(payload.length + 6 === size);
|
|
30
|
-
});
|
|
31
|
-
it(`Negative: Unexpected option 'flag' returns Error`, async () => {
|
|
32
|
-
const payload = chance.paragraph();
|
|
33
|
-
await (0, expect_1.expect)(async () => {
|
|
34
|
-
await src_1.pfs.append('./tmpdir/tings.txt', payload, {
|
|
35
|
-
flag: 'r'
|
|
36
|
-
});
|
|
37
|
-
})
|
|
38
|
-
.rejects
|
|
39
|
-
.toThrow();
|
|
40
|
-
});
|
|
41
|
-
it(`[sync] Positive: Must append content to file`, () => {
|
|
42
|
-
const payload = chance.paragraph();
|
|
43
|
-
src_1.pfs.append('./tmpdir/tings.txt', payload, {
|
|
44
|
-
sync: true
|
|
45
|
-
});
|
|
46
|
-
const { size } = node_fs_1.default.statSync('./tmpdir/tings.txt');
|
|
47
|
-
(0, node_assert_1.default)(payload.length + 6 === size);
|
|
48
|
-
});
|
|
49
|
-
it(`[sync] Negative: Unexpected option 'flag' returns Error`, () => {
|
|
50
|
-
const payload = chance.paragraph();
|
|
51
|
-
node_assert_1.default.throws(() => {
|
|
52
|
-
src_1.pfs.append('./tmpdir/tings.txt', payload, {
|
|
53
|
-
sync: true,
|
|
54
|
-
flag: 'r'
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/test/bitmask.spec.js
DELETED
|
@@ -1,26 +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 src_1 = require("../src");
|
|
8
|
-
describe('static bitmask(mode: number)', () => {
|
|
9
|
-
it('Positive: Calculate bitmask', () => {
|
|
10
|
-
(0, node_assert_1.default)((0, src_1.bitmask)(33024) === 0o400); // (r--------)
|
|
11
|
-
(0, node_assert_1.default)((0, src_1.bitmask)(33152) === 0o600); // (rw-------)
|
|
12
|
-
(0, node_assert_1.default)((0, src_1.bitmask)(33216) === 0o700); // (rwx------)
|
|
13
|
-
(0, node_assert_1.default)((0, src_1.bitmask)(32800) === 0o040); // (---r-----)
|
|
14
|
-
(0, node_assert_1.default)((0, src_1.bitmask)(32816) === 0o060); // (---rw----)
|
|
15
|
-
(0, node_assert_1.default)((0, src_1.bitmask)(32824) === 0o070); // (---rwx---)
|
|
16
|
-
(0, node_assert_1.default)((0, src_1.bitmask)(32772) === 0o004); // (------r--)
|
|
17
|
-
(0, node_assert_1.default)((0, src_1.bitmask)(32774) === 0o006); // (------rw-)
|
|
18
|
-
(0, node_assert_1.default)((0, src_1.bitmask)(32775) === 0o007); // (------rwx)
|
|
19
|
-
});
|
|
20
|
-
it(`Negative: Throw an exception if the argument is 'null' type`, () => {
|
|
21
|
-
node_assert_1.default.throws(() => {
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
(0, src_1.bitmask)(null);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
});
|
package/lib/test/chmod.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/test/chmod.spec.js
DELETED
|
@@ -1,62 +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('chmod(src, mode [, 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: Changes directory and file permissions', async () => {
|
|
26
|
-
await src_1.pfs.chmod('./tmpdir', 0o744);
|
|
27
|
-
const { mode } = node_fs_1.default.lstatSync('./tmpdir/tings.txt');
|
|
28
|
-
const umask = (0, src_1.bitmask)(mode);
|
|
29
|
-
(0, node_assert_1.default)(umask === 0o744);
|
|
30
|
-
});
|
|
31
|
-
it('Negative: Throw if not exists resource', async () => {
|
|
32
|
-
await (0, expect_1.expect)(async () => {
|
|
33
|
-
await src_1.pfs.chmod('./non-existent-source', 0o744);
|
|
34
|
-
})
|
|
35
|
-
.rejects
|
|
36
|
-
.toThrow();
|
|
37
|
-
});
|
|
38
|
-
it(`[sync] Positive: Changes permissions of directory`, () => {
|
|
39
|
-
src_1.pfs.chmod('./tmpdir', 0o744, {
|
|
40
|
-
sync: true
|
|
41
|
-
});
|
|
42
|
-
const { mode } = node_fs_1.default.lstatSync('./tmpdir');
|
|
43
|
-
const umask = (0, src_1.bitmask)(mode);
|
|
44
|
-
(0, node_assert_1.default)(umask === 0o744);
|
|
45
|
-
});
|
|
46
|
-
it(`[sync] Positive: Changes file permissions`, () => {
|
|
47
|
-
src_1.pfs.chmod('./tmpdir', 0o744, {
|
|
48
|
-
sync: true
|
|
49
|
-
});
|
|
50
|
-
const { mode } = node_fs_1.default.lstatSync('./tmpdir/tings.txt');
|
|
51
|
-
const umask = (0, src_1.bitmask)(mode);
|
|
52
|
-
(0, node_assert_1.default)(umask === 0o744);
|
|
53
|
-
});
|
|
54
|
-
it('[sync] Negative: Throw if not exists resource', () => {
|
|
55
|
-
const guid = chance.guid();
|
|
56
|
-
node_assert_1.default.throws(() => {
|
|
57
|
-
src_1.pfs.chmod(`./${guid}`, 0o744, {
|
|
58
|
-
sync: true
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
});
|
package/lib/test/chown.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/test/chown.spec.js
DELETED
|
@@ -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('chown(src, [, 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
|
-
'./tmpdir/digest/': { type: 'directory' }
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
afterEach(() => {
|
|
24
|
-
(0, __fmock_1.restore)('./tmpdir');
|
|
25
|
-
});
|
|
26
|
-
it('Positive: Changes the permissions of a file', async () => {
|
|
27
|
-
const { uid, gid } = node_fs_1.default.statSync('./tmpdir/tings.txt');
|
|
28
|
-
await src_1.pfs.chown('./tmpdir/tings.txt', { uid, gid });
|
|
29
|
-
(0, node_assert_1.default)(uid && gid);
|
|
30
|
-
});
|
|
31
|
-
it('Positive: Changes the permissions of a directory', async () => {
|
|
32
|
-
const { uid, gid } = node_fs_1.default.statSync('./tmpdir/digest');
|
|
33
|
-
await src_1.pfs.chown('./tmpdir/digest', { uid, gid });
|
|
34
|
-
(0, node_assert_1.default)(uid && gid);
|
|
35
|
-
});
|
|
36
|
-
it('Negative: To a non-existent resource to return an Error', async () => {
|
|
37
|
-
const guid = chance.guid();
|
|
38
|
-
const { uid, gid } = node_fs_1.default.statSync('./tmpdir/tings.txt');
|
|
39
|
-
await (0, expect_1.expect)(async () => {
|
|
40
|
-
await src_1.pfs.chown(`./tmpdir/${guid}`, { uid, gid });
|
|
41
|
-
})
|
|
42
|
-
.rejects
|
|
43
|
-
.toThrow();
|
|
44
|
-
});
|
|
45
|
-
it('[sync] Positive: Changes the permissions of a file', () => {
|
|
46
|
-
const { uid, gid } = node_fs_1.default.statSync('./tmpdir/tings.txt');
|
|
47
|
-
src_1.pfs.chown('./tmpdir/tings.txt', {
|
|
48
|
-
sync: true,
|
|
49
|
-
uid,
|
|
50
|
-
gid
|
|
51
|
-
});
|
|
52
|
-
(0, node_assert_1.default)(uid && gid);
|
|
53
|
-
});
|
|
54
|
-
it('[sync] Positive: Changes the permissions of a directory', () => {
|
|
55
|
-
const { uid, gid } = node_fs_1.default.statSync('./tmpdir/digest');
|
|
56
|
-
src_1.pfs.chown('./tmpdir/digest', {
|
|
57
|
-
sync: true,
|
|
58
|
-
uid,
|
|
59
|
-
gid
|
|
60
|
-
});
|
|
61
|
-
(0, node_assert_1.default)(uid && gid);
|
|
62
|
-
});
|
|
63
|
-
it('[sync] Negative: To a non-existent resource to return an Error', () => {
|
|
64
|
-
const guid = chance.guid();
|
|
65
|
-
const { uid, gid } = node_fs_1.default.statSync('./tmpdir/tings.txt');
|
|
66
|
-
node_assert_1.default.throws(() => {
|
|
67
|
-
src_1.pfs.chown(`./tmpdir/${guid}`, {
|
|
68
|
-
sync: true,
|
|
69
|
-
uid,
|
|
70
|
-
gid
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,17 +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 src_1 = require("../src");
|
|
8
|
-
describe('#constructor: new PoweredFileSystem(pwd?)', () => {
|
|
9
|
-
it('Positive: An empty path must match the context of the cwd', () => {
|
|
10
|
-
const { pwd } = new src_1.PoweredFileSystem();
|
|
11
|
-
(0, node_assert_1.default)(pwd === process.cwd());
|
|
12
|
-
});
|
|
13
|
-
it('Positive: Absolute path must match the context of the pwd', () => {
|
|
14
|
-
const { pwd } = new src_1.PoweredFileSystem(__dirname);
|
|
15
|
-
(0, node_assert_1.default)(pwd === __dirname);
|
|
16
|
-
});
|
|
17
|
-
});
|
package/lib/test/copy.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/test/copy.spec.js
DELETED
|
@@ -1,80 +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('copy(src, dir [, 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
|
-
'./tmpdir/digest/': { type: 'directory' }
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
afterEach(() => {
|
|
24
|
-
(0, __fmock_1.restore)('./tmpdir');
|
|
25
|
-
});
|
|
26
|
-
it('Positive: Copying a item file', async () => {
|
|
27
|
-
await src_1.pfs.copy('./tmpdir/tings.txt', './tmpdir/digest');
|
|
28
|
-
const exist = node_fs_1.default.existsSync(`./tmpdir/digest/tings.txt`);
|
|
29
|
-
(0, node_assert_1.default)(exist);
|
|
30
|
-
});
|
|
31
|
-
it('Positive: Recursive copying a directory', async () => {
|
|
32
|
-
await src_1.pfs.copy('./src', './tmpdir');
|
|
33
|
-
const exist = node_fs_1.default.existsSync(`./tmpdir/src`);
|
|
34
|
-
(0, node_assert_1.default)(exist);
|
|
35
|
-
});
|
|
36
|
-
it('Negative: Throw if not exists resource', async () => {
|
|
37
|
-
const guid = chance.guid();
|
|
38
|
-
await (0, expect_1.expect)(async () => {
|
|
39
|
-
await src_1.pfs.copy(`./${guid}`, '.');
|
|
40
|
-
})
|
|
41
|
-
.rejects
|
|
42
|
-
.toThrow();
|
|
43
|
-
});
|
|
44
|
-
it('Negative: An attempt to copy to an existing resource should return an Error', async () => {
|
|
45
|
-
await (0, expect_1.expect)(async () => {
|
|
46
|
-
await src_1.pfs.copy('./tmpdir', '.');
|
|
47
|
-
})
|
|
48
|
-
.rejects
|
|
49
|
-
.toThrow();
|
|
50
|
-
});
|
|
51
|
-
it('[sync] Positive: Copying a file', () => {
|
|
52
|
-
src_1.pfs.copy('./tmpdir/tings.txt', './tmpdir/digest', {
|
|
53
|
-
sync: true
|
|
54
|
-
});
|
|
55
|
-
const exist = node_fs_1.default.existsSync(`./tmpdir/digest/tings.txt`);
|
|
56
|
-
(0, node_assert_1.default)(exist);
|
|
57
|
-
});
|
|
58
|
-
it('[sync] Positive: Recursive copying a directory', () => {
|
|
59
|
-
src_1.pfs.copy('./src', './tmpdir', {
|
|
60
|
-
sync: true
|
|
61
|
-
});
|
|
62
|
-
const exist = node_fs_1.default.existsSync(`./tmpdir/src`);
|
|
63
|
-
(0, node_assert_1.default)(exist);
|
|
64
|
-
});
|
|
65
|
-
it('[sync] Negative: Throw if not exists resource', () => {
|
|
66
|
-
const guid = chance.guid();
|
|
67
|
-
node_assert_1.default.throws(() => {
|
|
68
|
-
src_1.pfs.copy(`./${guid}`, '.', {
|
|
69
|
-
sync: true
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
it('[sync] Negative: An attempt to copy to an existing resource should return an Error', () => {
|
|
74
|
-
node_assert_1.default.throws(() => {
|
|
75
|
-
src_1.pfs.copy('./tmpdir', '.', {
|
|
76
|
-
sync: true
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
});
|
package/lib/test/mkdir.spec.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|