pwd-fs 2.4.2 → 3.1.4

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 (68) hide show
  1. package/.travis.yml +2 -3
  2. package/appveyor.yml +2 -4
  3. package/lib/src/index.d.ts +4 -186
  4. package/lib/src/index.js +18 -294
  5. package/lib/src/powered-file-system.d.ts +156 -0
  6. package/lib/src/powered-file-system.js +264 -0
  7. package/lib/src/recurse-io-sync.d.ts +10 -5
  8. package/lib/src/recurse-io-sync.js +74 -69
  9. package/lib/src/recurse-io.d.ts +14 -6
  10. package/lib/src/recurse-io.js +164 -160
  11. package/lib/test/__fmock.d.ts +5 -0
  12. package/lib/test/__fmock.js +40 -0
  13. package/lib/test/append.spec.js +36 -77
  14. package/lib/test/bitmask.spec.js +14 -17
  15. package/lib/test/chmod.spec.js +42 -84
  16. package/lib/test/chown.spec.js +45 -71
  17. package/lib/test/constructor.spec.js +7 -10
  18. package/lib/test/copy.spec.js +53 -108
  19. package/lib/test/mkdir.spec.js +62 -119
  20. package/lib/test/read.spec.js +47 -78
  21. package/lib/test/readdir.spec.js +48 -90
  22. package/lib/test/remove.spec.js +44 -65
  23. package/lib/test/rename.spec.js +43 -75
  24. package/lib/test/stat.spec.js +50 -78
  25. package/lib/test/symlink.spec.js +51 -95
  26. package/lib/test/test.spec.js +37 -66
  27. package/lib/test/write.spec.js +52 -103
  28. package/package.json +8 -11
  29. package/readme.md +10 -21
  30. package/src/index.ts +4 -623
  31. package/src/powered-file-system.ts +527 -0
  32. package/src/recurse-io-sync.ts +77 -71
  33. package/src/recurse-io.ts +181 -176
  34. package/test/__fmock.ts +45 -0
  35. package/test/append.spec.ts +44 -98
  36. package/test/bitmask.spec.ts +14 -17
  37. package/test/chmod.spec.ts +45 -95
  38. package/test/chown.spec.ts +61 -93
  39. package/test/constructor.spec.ts +4 -7
  40. package/test/copy.spec.ts +72 -142
  41. package/test/mkdir.spec.ts +87 -153
  42. package/test/read.spec.ts +64 -103
  43. package/test/readdir.spec.ts +65 -113
  44. package/test/remove.spec.ts +58 -82
  45. package/test/rename.spec.ts +58 -96
  46. package/test/stat.spec.ts +68 -100
  47. package/test/symlink.spec.ts +74 -125
  48. package/test/test.spec.ts +51 -84
  49. package/test/write.spec.ts +68 -131
  50. package/tsconfig.json +14 -7
  51. package/lib/src/index.js.map +0 -1
  52. package/lib/src/recurse-io-sync.js.map +0 -1
  53. package/lib/src/recurse-io.js.map +0 -1
  54. package/lib/test/append.spec.js.map +0 -1
  55. package/lib/test/bitmask.spec.js.map +0 -1
  56. package/lib/test/chmod.spec.js.map +0 -1
  57. package/lib/test/chown.spec.js.map +0 -1
  58. package/lib/test/constructor.spec.js.map +0 -1
  59. package/lib/test/copy.spec.js.map +0 -1
  60. package/lib/test/mkdir.spec.js.map +0 -1
  61. package/lib/test/read.spec.js.map +0 -1
  62. package/lib/test/readdir.spec.js.map +0 -1
  63. package/lib/test/remove.spec.js.map +0 -1
  64. package/lib/test/rename.spec.js.map +0 -1
  65. package/lib/test/stat.spec.js.map +0 -1
  66. package/lib/test/symlink.spec.js.map +0 -1
  67. package/lib/test/test.spec.js.map +0 -1
  68. package/lib/test/write.spec.js.map +0 -1
@@ -3,102 +3,60 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const assert_1 = __importDefault(require("assert"));
7
- const path_1 = require("path");
8
- const mock_fs_1 = __importDefault(require("mock-fs"));
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
9
8
  const chance_1 = __importDefault(require("chance"));
10
- const src_1 = __importDefault(require("../src"));
9
+ const expect_1 = require("expect");
10
+ const __fmock_1 = require("./__fmock");
11
+ const src_1 = require("../src");
11
12
  describe('chmod(src, mode [, options])', () => {
13
+ const chance = new chance_1.default();
12
14
  beforeEach(() => {
13
- const chance = new chance_1.default();
14
- (0, mock_fs_1.default)({
15
- 'tmpdir': {
16
- 'binapp': chance.string(),
17
- 'libxbase': mock_fs_1.default.directory()
18
- },
19
- 'flexapp': mock_fs_1.default.symlink({
20
- path: 'tmpdir/binapp'
21
- })
15
+ (0, __fmock_1.fmock)({
16
+ './tmpdir/tings.txt': {
17
+ type: 'file',
18
+ data: chance.string()
19
+ }
22
20
  });
23
21
  });
24
- afterEach(mock_fs_1.default.restore);
22
+ afterEach(() => {
23
+ (0, __fmock_1.restore)('./tmpdir');
24
+ });
25
25
  it('Positive: Changes directory and file permissions', async () => {
26
- const pfs = new src_1.default();
27
- await pfs.chmod('./tmpdir', 0o744);
28
- const { mode } = await pfs.stat('./tmpdir/binapp');
29
- const umask = src_1.default.bitmask(mode);
30
- (0, assert_1.default)(umask === 0o744);
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);
31
30
  });
32
- it('Positive: Must be changes directory when path is absolute', async () => {
33
- const pfs = new src_1.default();
34
- const cwd = process.cwd();
35
- await pfs.chmod(`${cwd}${path_1.sep}tmpdir${path_1.sep}libxbase`, 0o744, {
36
- resolve: false
37
- });
38
- const { mode } = await pfs.stat('./tmpdir/libxbase');
39
- const umask = src_1.default.bitmask(mode);
40
- (0, assert_1.default)(umask === 0o744);
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();
41
37
  });
42
- it('Negative: Search permission is denied on a component of the path prefix', async () => {
43
- const pfs = new src_1.default();
44
- try {
45
- await pfs.chmod('./tmpdir', 0);
46
- }
47
- catch (err) {
48
- (0, assert_1.default)(err.errno === -9);
49
- }
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);
50
45
  });
51
- it('Negative: Throw if not exists resource', async () => {
52
- const pfs = new src_1.default();
53
- try {
54
- await pfs.chmod('./non-existent-source', 0o744);
55
- }
56
- catch (err) {
57
- (0, assert_1.default)(err.errno === -2);
58
- }
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);
59
53
  });
60
- describe('sync mode', () => {
61
- it(`Positive: Changes directory and file permissions`, async () => {
62
- const pfs = new src_1.default();
63
- pfs.chmod('./tmpdir', 0o744, {
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, {
64
58
  sync: true
65
59
  });
66
- const { mode } = await pfs.stat('./tmpdir/binapp');
67
- const umask = src_1.default.bitmask(mode);
68
- (0, assert_1.default)(umask === 0o744);
69
- });
70
- it('Positive: Must be changes directory when path is absolute', async () => {
71
- const pfs = new src_1.default();
72
- const cwd = process.cwd();
73
- pfs.chmod(`${cwd}${path_1.sep}tmpdir${path_1.sep}libxbase`, 0o744, {
74
- sync: true,
75
- resolve: false
76
- });
77
- const { mode } = await pfs.stat('./tmpdir/libxbase');
78
- const umask = src_1.default.bitmask(mode);
79
- (0, assert_1.default)(umask === 0o744);
80
- });
81
- it('Negative: Search permission is denied on a component of the path prefix', async () => {
82
- const pfs = new src_1.default();
83
- try {
84
- pfs.chmod('./tmpdir', 0, {
85
- sync: true
86
- });
87
- }
88
- catch (err) {
89
- (0, assert_1.default)(err.errno === -9);
90
- }
91
- });
92
- it('Negative: Throw if not exists resource', async () => {
93
- const pfs = new src_1.default();
94
- try {
95
- pfs.chmod('./non-existent-source', 0o744, {
96
- sync: true
97
- });
98
- }
99
- catch (err) {
100
- (0, assert_1.default)(err.errno === -2);
101
- }
102
60
  });
103
61
  });
104
62
  });
@@ -3,92 +3,66 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const assert_1 = __importDefault(require("assert"));
7
- const path_1 = require("path");
8
- const mock_fs_1 = __importDefault(require("mock-fs"));
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
9
8
  const chance_1 = __importDefault(require("chance"));
10
- const src_1 = __importDefault(require("../src"));
9
+ const expect_1 = require("expect");
10
+ const __fmock_1 = require("./__fmock");
11
+ const src_1 = require("../src");
11
12
  describe('chown(src, uid, gid [, options])', () => {
13
+ const chance = new chance_1.default();
12
14
  beforeEach(() => {
13
- const chance = new chance_1.default();
14
- (0, mock_fs_1.default)({
15
- 'tmpdir': {
16
- 'binapp': chance.string(),
17
- 'libxbase': mock_fs_1.default.directory()
15
+ (0, __fmock_1.fmock)({
16
+ './tmpdir/tings.txt': {
17
+ type: 'file',
18
+ data: chance.string()
18
19
  },
19
- 'flexapp': mock_fs_1.default.symlink({
20
- path: 'tmpdir/binapp'
21
- })
20
+ './tmpdir/digest/': { type: 'directory' }
22
21
  });
23
22
  });
24
- afterEach(mock_fs_1.default.restore);
23
+ afterEach(() => {
24
+ (0, __fmock_1.restore)('./tmpdir');
25
+ });
25
26
  it('Positive: Changes the permissions of a file', async () => {
26
- const pfs = new src_1.default();
27
- await pfs.chown('./tmpdir', 0, 0);
28
- const { uid, gid } = await pfs.stat('./tmpdir');
29
- (0, assert_1.default)(uid === 0 && gid === 0);
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
30
  });
31
31
  it('Positive: Changes the permissions of a directory', async () => {
32
- const pfs = new src_1.default();
33
- await pfs.chown('./tmpdir/libxbase', 0, 0);
34
- const { uid, gid } = await pfs.stat('./tmpdir/libxbase');
35
- (0, assert_1.default)(uid === 0 && gid === 0);
36
- });
37
- it('Positive: Changes the permissions of a file, when path is absolute', async () => {
38
- const pfs = new src_1.default();
39
- const cwd = process.cwd();
40
- await pfs.chown(`${cwd}${path_1.sep}tmpdir${path_1.sep}binapp`, 1, 1, {
41
- resolve: false
42
- });
43
- const { uid, gid } = await pfs.stat('./tmpdir/binapp');
44
- (0, assert_1.default)(uid === 1 && gid === 1);
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);
45
35
  });
46
36
  it('Negative: To a non-existent resource to return an Error', async () => {
47
- const pfs = new src_1.default();
48
- try {
49
- await pfs.chown('./non-existent-source', 1, 1);
50
- }
51
- catch (err) {
52
- (0, assert_1.default)(err.errno === -2);
53
- }
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();
54
44
  });
55
- describe('sync mode', () => {
56
- it('Positive: Changes the permissions of a file', async () => {
57
- const pfs = new src_1.default();
58
- pfs.chown('./tmpdir/binapp', 1, 1, {
59
- sync: true
60
- });
61
- const { uid, gid } = await pfs.stat('./tmpdir/binapp');
62
- (0, assert_1.default)(uid === 1 && gid === 1);
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', uid, gid, {
48
+ sync: true
63
49
  });
64
- it('Positive: Changes the permissions of a directory', async () => {
65
- const pfs = new src_1.default();
66
- pfs.chown('./tmpdir', 1, 1, {
67
- sync: true
68
- });
69
- const { uid, gid } = await pfs.stat('./tmpdir');
70
- (0, assert_1.default)(uid === 1 && gid === 1);
50
+ (0, node_assert_1.default)(uid && gid);
51
+ });
52
+ it('[sync] Positive: Changes the permissions of a directory', () => {
53
+ const { uid, gid } = node_fs_1.default.statSync('./tmpdir/digest');
54
+ src_1.pfs.chown('./tmpdir/digest', uid, gid, {
55
+ sync: true
71
56
  });
72
- it('Positive: Changes the permissions of a file, when path is absolute', async () => {
73
- const pfs = new src_1.default();
74
- const cwd = process.cwd();
75
- pfs.chown(`${cwd}${path_1.sep}tmpdir${path_1.sep}binapp`, 1, 1, {
76
- sync: true,
77
- resolve: false
57
+ (0, node_assert_1.default)(uid && gid);
58
+ });
59
+ it('[sync] Negative: To a non-existent resource to return an Error', () => {
60
+ const guid = chance.guid();
61
+ const { uid, gid } = node_fs_1.default.statSync('./tmpdir/tings.txt');
62
+ node_assert_1.default.throws(() => {
63
+ src_1.pfs.chown(`./tmpdir/${guid}`, uid, gid, {
64
+ sync: true
78
65
  });
79
- const { uid, gid } = await pfs.stat('./tmpdir/binapp');
80
- (0, assert_1.default)(uid === 1 && gid === 1);
81
- });
82
- it(`Negative: To a non-existent resource to return an Error`, async () => {
83
- const pfs = new src_1.default();
84
- try {
85
- pfs.chown('./non-existent-source', 1, 1, {
86
- sync: true
87
- });
88
- }
89
- catch (err) {
90
- (0, assert_1.default)(err.errno === -2);
91
- }
92
66
  });
93
67
  });
94
68
  });
@@ -3,18 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const assert_1 = __importDefault(require("assert"));
7
- const src_1 = __importDefault(require("../src"));
8
- describe('#constructor: new PoweredFileSystem(path)', () => {
9
- it('Positive: Must be backwards compatible with #require', () => {
10
- (0, assert_1.default)(require('../src') === src_1.default);
11
- });
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const src_1 = require("../src");
8
+ describe('#constructor: new PoweredFileSystem(pwd?)', () => {
12
9
  it('Positive: An empty path must match the context of the cwd', () => {
13
- const { pwd } = new src_1.default();
14
- (0, assert_1.default)(pwd === process.cwd());
10
+ const { pwd } = new src_1.PoweredFileSystem();
11
+ (0, node_assert_1.default)(pwd === process.cwd());
15
12
  });
16
13
  it('Positive: Absolute path must match the context of the pwd', () => {
17
- const { pwd } = new src_1.default(__dirname);
18
- (0, assert_1.default)(pwd === __dirname);
14
+ const { pwd } = new src_1.PoweredFileSystem(__dirname);
15
+ (0, node_assert_1.default)(pwd === __dirname);
19
16
  });
20
17
  });
@@ -3,133 +3,78 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const assert_1 = __importDefault(require("assert"));
7
- const os_1 = __importDefault(require("os"));
8
- const path_1 = require("path");
9
- const mock_fs_1 = __importDefault(require("mock-fs"));
6
+ const node_assert_1 = __importDefault(require("node:assert"));
7
+ const node_fs_1 = __importDefault(require("node:fs"));
10
8
  const chance_1 = __importDefault(require("chance"));
11
- const src_1 = __importDefault(require("../src"));
9
+ const expect_1 = require("expect");
10
+ const __fmock_1 = require("./__fmock");
11
+ const src_1 = require("../src");
12
12
  describe('copy(src, dir [, options])', () => {
13
+ const chance = new chance_1.default();
13
14
  beforeEach(() => {
14
- const chance = new chance_1.default();
15
- (0, mock_fs_1.default)({
16
- 'tmpdir': {
17
- 'binapp': chance.string(),
18
- 'libxbase': mock_fs_1.default.directory()
15
+ (0, __fmock_1.fmock)({
16
+ './tmpdir/tings.txt': {
17
+ type: 'file',
18
+ data: chance.string()
19
19
  },
20
- 'flexapp': mock_fs_1.default.symlink({
21
- path: 'tmpdir/binapp'
22
- })
20
+ './tmpdir/digest/': { type: 'directory' }
23
21
  });
24
22
  });
25
- afterEach(mock_fs_1.default.restore);
23
+ afterEach(() => {
24
+ (0, __fmock_1.restore)('./tmpdir');
25
+ });
26
26
  it('Positive: Copying a item file', async () => {
27
- const pfs = new src_1.default();
28
- const dist = os_1.default.tmpdir();
29
- await pfs.copy('./tmpdir/binapp', dist);
30
- const { mode } = await pfs.stat(`${dist}/binapp`);
31
- const umask = src_1.default.bitmask(mode);
32
- (0, assert_1.default)(umask === 0o666);
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);
33
30
  });
34
31
  it('Positive: Recursive copying a directory', async () => {
35
- const pfs = new src_1.default();
36
- const dist = os_1.default.tmpdir();
37
- await pfs.copy('./tmpdir', dist);
38
- const { mode } = await pfs.stat(`${dist}/tmpdir/libxbase`);
39
- const umask = src_1.default.bitmask(mode);
40
- (0, assert_1.default)(umask === 0o777);
41
- });
42
- it('Positive: Recursive copying a directory. Permission check of file', async () => {
43
- const pfs = new src_1.default();
44
- const dist = os_1.default.tmpdir();
45
- await pfs.copy('./tmpdir', dist);
46
- const { mode } = await pfs.stat(`${dist}/tmpdir/binapp`);
47
- const umask = src_1.default.bitmask(mode);
48
- (0, assert_1.default)(umask === 0o666);
49
- });
50
- it('Positive: Copying a item file when path is absolute', async () => {
51
- const pfs = new src_1.default();
52
- const cwd = process.cwd();
53
- const dist = os_1.default.tmpdir();
54
- await pfs.copy(`${cwd}${path_1.sep}tmpdir`, dist, {
55
- resolve: false
56
- });
57
- const { mode } = await pfs.stat(`${dist}/tmpdir/binapp`);
58
- const umask = src_1.default.bitmask(mode);
59
- (0, assert_1.default)(umask === 0o666);
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);
60
35
  });
61
36
  it('Negative: Throw if not exists resource', async () => {
62
- const pfs = new src_1.default();
63
- try {
64
- await pfs.copy('./non-existent', '.');
65
- }
66
- catch (err) {
67
- (0, assert_1.default)(err.errno === -2);
68
- }
37
+ const guid = chance.guid();
38
+ await (0, expect_1.expect)(async () => {
39
+ await src_1.pfs.copy(`./${guid}`, '.');
40
+ })
41
+ .rejects
42
+ .toThrow();
69
43
  });
70
44
  it('Negative: An attempt to copy to an existing resource should return an Error', async () => {
71
- const pfs = new src_1.default();
72
- try {
73
- await pfs.copy('./tmpdir', '.');
74
- }
75
- catch (err) {
76
- (0, assert_1.default)(err.errno === -17);
77
- }
45
+ await (0, expect_1.expect)(async () => {
46
+ await src_1.pfs.copy('./tmpdir', '.');
47
+ })
48
+ .rejects
49
+ .toThrow();
78
50
  });
79
- describe('sync mode', () => {
80
- it('Positive: Copying a file', async () => {
81
- const pfs = new src_1.default();
82
- const dist = os_1.default.tmpdir();
83
- pfs.copy('./tmpdir/binapp', dist, {
84
- sync: true
85
- });
86
- const { mode } = await pfs.stat(`${dist}/binapp`);
87
- const umask = src_1.default.bitmask(mode);
88
- (0, assert_1.default)(umask === 0o666);
51
+ it('[sync] Positive: Copying a file', () => {
52
+ src_1.pfs.copy('./tmpdir/tings.txt', './tmpdir/digest', {
53
+ sync: true
89
54
  });
90
- it('Positive: Recursive copying a directory', async () => {
91
- const pfs = new src_1.default();
92
- const dist = os_1.default.tmpdir();
93
- pfs.copy('./tmpdir', dist, {
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}`, '.', {
94
69
  sync: true
95
70
  });
96
- const { mode } = await pfs.stat(`${dist}/tmpdir/libxbase`);
97
- const umask = src_1.default.bitmask(mode);
98
- (0, assert_1.default)(umask === 0o777);
99
71
  });
100
- it('Positive: Copying a item file when path is absolute', async () => {
101
- const pfs = new src_1.default();
102
- const cwd = process.cwd();
103
- const dist = os_1.default.tmpdir();
104
- pfs.copy(`${cwd}${path_1.sep}tmpdir`, dist, {
105
- sync: true,
106
- resolve: false
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
107
77
  });
108
- const { mode } = await pfs.stat(`${dist}/tmpdir/binapp`);
109
- const umask = src_1.default.bitmask(mode);
110
- (0, assert_1.default)(umask === 0o666);
111
- });
112
- it('Negative: Throw if not exists resource', async () => {
113
- const pfs = new src_1.default();
114
- try {
115
- pfs.copy('./non-existent', '.', {
116
- sync: true
117
- });
118
- }
119
- catch (err) {
120
- (0, assert_1.default)(err.errno === -2);
121
- }
122
- });
123
- it('Negative: An attempt to copy to an existing resource should return an Error', async () => {
124
- const pfs = new src_1.default();
125
- try {
126
- pfs.copy('./tmpdir', '.', {
127
- sync: true
128
- });
129
- }
130
- catch (err) {
131
- (0, assert_1.default)(err.errno === -17);
132
- }
133
78
  });
134
79
  });
135
80
  });