pwd-fs 3.1.3 → 3.2.0

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 (70) hide show
  1. package/lib/src/bitmask.d.ts +1 -0
  2. package/lib/src/bitmask.js +18 -0
  3. package/lib/src/index.d.ts +3 -5
  4. package/lib/src/index.js +21 -0
  5. package/lib/src/powered-file-system.d.ts +21 -3
  6. package/lib/{powered-file-system.js → src/powered-file-system.js} +69 -67
  7. package/lib/src/recurse-io-sync.d.ts +5 -13
  8. package/lib/src/recurse-io-sync.js +93 -0
  9. package/lib/src/recurse-io.d.ts +6 -16
  10. package/lib/{recurse-io.js → src/recurse-io.js} +44 -41
  11. package/lib/test/__fmock.js +40 -0
  12. package/lib/test/append.spec.js +58 -0
  13. package/lib/test/bitmask.spec.js +26 -0
  14. package/lib/test/chmod.spec.js +62 -0
  15. package/lib/test/chown.spec.js +74 -0
  16. package/lib/test/constructor.spec.js +17 -0
  17. package/lib/test/copy.spec.js +80 -0
  18. package/lib/test/mkdir.spec.js +90 -0
  19. package/lib/test/read.spec.js +73 -0
  20. package/lib/test/readdir.spec.js +70 -0
  21. package/lib/test/remove.spec.js +63 -0
  22. package/lib/test/rename.spec.js +66 -0
  23. package/lib/test/stat.spec.js +76 -0
  24. package/lib/test/symlink.spec.js +74 -0
  25. package/lib/test/test.spec.js +60 -0
  26. package/lib/test/write.spec.js +82 -0
  27. package/package.json +8 -15
  28. package/readme.md +14 -12
  29. package/src/bitmask.ts +20 -0
  30. package/src/index.ts +4 -26
  31. package/src/powered-file-system.ts +50 -52
  32. package/src/recurse-io-sync.ts +24 -24
  33. package/src/recurse-io.ts +18 -19
  34. package/{__tests__ → test}/append.spec.ts +2 -3
  35. package/{__tests__ → test}/chmod.spec.ts +2 -3
  36. package/{__tests__ → test}/chown.spec.ts +18 -14
  37. package/{__tests__ → test}/constructor.spec.ts +1 -1
  38. package/{__tests__ → test}/copy.spec.ts +2 -3
  39. package/{__tests__ → test}/mkdir.spec.ts +2 -1
  40. package/{__tests__ → test}/read.spec.ts +2 -3
  41. package/{__tests__ → test}/readdir.spec.ts +3 -4
  42. package/{__tests__ → test}/remove.spec.ts +3 -3
  43. package/{__tests__ → test}/rename.spec.ts +2 -2
  44. package/{__tests__ → test}/stat.spec.ts +2 -3
  45. package/{__tests__ → test}/symlink.spec.ts +3 -3
  46. package/{__tests__ → test}/test.spec.ts +1 -3
  47. package/{__tests__ → test}/write.spec.ts +2 -2
  48. package/tsconfig.json +5 -5
  49. package/jest.config.ts +0 -14
  50. package/lib/index.js +0 -24
  51. package/lib/recurse-io-sync.js +0 -90
  52. package/rollup.config.js +0 -16
  53. /package/lib/{__tests__ → test}/__fmock.d.ts +0 -0
  54. /package/lib/{__tests__ → test}/append.spec.d.ts +0 -0
  55. /package/lib/{__tests__ → test}/bitmask.spec.d.ts +0 -0
  56. /package/lib/{__tests__ → test}/chmod.spec.d.ts +0 -0
  57. /package/lib/{__tests__ → test}/chown.spec.d.ts +0 -0
  58. /package/lib/{__tests__ → test}/constructor.spec.d.ts +0 -0
  59. /package/lib/{__tests__ → test}/copy.spec.d.ts +0 -0
  60. /package/lib/{__tests__ → test}/mkdir.spec.d.ts +0 -0
  61. /package/lib/{__tests__ → test}/read.spec.d.ts +0 -0
  62. /package/lib/{__tests__ → test}/readdir.spec.d.ts +0 -0
  63. /package/lib/{__tests__ → test}/remove.spec.d.ts +0 -0
  64. /package/lib/{__tests__ → test}/rename.spec.d.ts +0 -0
  65. /package/lib/{__tests__ → test}/stat.spec.d.ts +0 -0
  66. /package/lib/{__tests__ → test}/symlink.spec.d.ts +0 -0
  67. /package/lib/{__tests__ → test}/test.spec.d.ts +0 -0
  68. /package/lib/{__tests__ → test}/write.spec.d.ts +0 -0
  69. /package/{__tests__ → test}/__fmock.ts +0 -0
  70. /package/{__tests__ → test}/bitmask.spec.ts +0 -0
@@ -1,5 +1,5 @@
1
1
  import assert from 'node:assert';
2
- import PoweredFileSystem from '../src';
2
+ import { PoweredFileSystem } from '../src';
3
3
 
4
4
  describe('#constructor: new PoweredFileSystem(pwd?)', () => {
5
5
  it('Positive: An empty path must match the context of the cwd', () => {
@@ -1,12 +1,11 @@
1
1
  import assert from 'node:assert';
2
- import { sep } from 'node:path';
3
2
  import fs from 'node:fs';
4
3
  import Chance from 'chance';
4
+ import { expect } from 'expect';
5
5
  import { fmock, restore } from './__fmock';
6
- import PoweredFileSystem, { bitmask } from '../src';
6
+ import { pfs } from '../src';
7
7
 
8
8
  describe('copy(src, dir [, options])', () => {
9
- const pfs = new PoweredFileSystem();
10
9
  const chance = new Chance();
11
10
 
12
11
  beforeEach(() => {
@@ -1,8 +1,9 @@
1
1
  import assert from 'node:assert';
2
2
  import fs from 'node:fs';
3
3
  import Chance from 'chance';
4
+ import { expect } from 'expect';
4
5
  import { fmock, restore } from './__fmock';
5
- import PoweredFileSystem from '../src';
6
+ import { PoweredFileSystem } from '../src';
6
7
 
7
8
  describe('mkdir(src [, options])', () => {
8
9
  const pfs = new PoweredFileSystem();
@@ -1,11 +1,10 @@
1
1
  import assert from 'node:assert';
2
- import fs from 'node:fs';
3
2
  import Chance from 'chance';
3
+ import { expect } from 'expect';
4
4
  import { fmock, restore } from './__fmock';
5
- import PoweredFileSystem from '../src';
5
+ import { pfs } from '../src';
6
6
 
7
7
  describe('read(src [, options])', () => {
8
- const pfs = new PoweredFileSystem();
9
8
  const chance = new Chance();
10
9
  let sentences = 0;
11
10
 
@@ -1,11 +1,10 @@
1
1
  import assert from 'node:assert';
2
- import fs from 'node:fs';
3
2
  import Chance from 'chance';
4
- import { type Iframe, fmock, restore } from './__fmock';
5
- import PoweredFileSystem from '../src';
3
+ import { expect } from 'expect';
4
+ import { Iframe, fmock, restore } from './__fmock';
5
+ import { pfs } from '../src';
6
6
 
7
7
  describe('readdir(src[, options])', () => {
8
- const pfs = new PoweredFileSystem();
9
8
  const chance = new Chance();
10
9
  let counter = 0;
11
10
 
@@ -1,11 +1,11 @@
1
1
  import assert from 'node:assert';
2
2
  import fs from 'node:fs';
3
3
  import Chance from 'chance';
4
- import { type Iframe, fmock, restore } from './__fmock';
5
- import PoweredFileSystem from '../src';
4
+ import { expect } from 'expect';
5
+ import { Iframe, fmock, restore } from './__fmock';
6
+ import { pfs } from '../src';
6
7
 
7
8
  describe('remove(src [, options])', () => {
8
- const pfs = new PoweredFileSystem();
9
9
  const chance = new Chance();
10
10
 
11
11
  beforeEach(() => {
@@ -1,11 +1,11 @@
1
1
  import assert from 'node:assert';
2
2
  import fs from 'node:fs';
3
3
  import Chance from 'chance';
4
+ import { expect } from 'expect';
4
5
  import { fmock, restore } from './__fmock';
5
- import PoweredFileSystem from '../src';
6
+ import {pfs } from '../src';
6
7
 
7
8
  describe('rename(src, use [, options])', () => {
8
- const pfs = new PoweredFileSystem();
9
9
  const chance = new Chance();
10
10
 
11
11
  beforeEach(() => {
@@ -1,11 +1,10 @@
1
1
  import assert from 'node:assert';
2
- import fs from 'node:fs';
3
2
  import Chance from 'chance';
3
+ import { expect } from 'expect';
4
4
  import { fmock, restore } from './__fmock';
5
- import PoweredFileSystem from '../src';
5
+ import { pfs } from '../src';
6
6
 
7
7
  describe('stat(src [, options])', () => {
8
- const pfs = new PoweredFileSystem();
9
8
  const chance = new Chance();
10
9
 
11
10
  beforeEach(() => {
@@ -1,11 +1,11 @@
1
1
  import assert from 'node:assert';
2
2
  import fs from 'node:fs';
3
3
  import Chance from 'chance';
4
- import { type Iframe, fmock, restore } from './__fmock';
5
- import PoweredFileSystem from '../src';
4
+ import { expect } from 'expect';
5
+ import { Iframe, fmock, restore } from './__fmock';
6
+ import { pfs } from '../src';
6
7
 
7
8
  describe('symlink(src, use [, options])', () => {
8
- const pfs = new PoweredFileSystem();
9
9
  const chance = new Chance();
10
10
 
11
11
  beforeEach(() => {
@@ -1,11 +1,9 @@
1
1
  import assert from 'node:assert';
2
- import fs from 'node:fs';
3
2
  import Chance from 'chance';
4
3
  import { fmock, restore } from './__fmock';
5
- import PoweredFileSystem from '../src';
4
+ import { pfs } from '../src';
6
5
 
7
6
  describe('test(src[, options])', () => {
8
- const pfs = new PoweredFileSystem();
9
7
  const chance = new Chance();
10
8
 
11
9
  beforeEach(() => {
@@ -1,11 +1,11 @@
1
1
  import assert from 'node:assert';
2
2
  import fs from 'node:fs';
3
3
  import Chance from 'chance';
4
+ import { expect } from 'expect';
4
5
  import { fmock, restore } from './__fmock';
5
- import PoweredFileSystem from '../src';
6
+ import { pfs } from '../src';
6
7
 
7
8
  describe('write(src, data[, options])', () => {
8
- const pfs = new PoweredFileSystem();
9
9
  const chance = new Chance();
10
10
 
11
11
  beforeEach(() => {
package/tsconfig.json CHANGED
@@ -3,17 +3,17 @@
3
3
  "lib": [
4
4
  "es2022"
5
5
  ],
6
- "module": "es2022",
6
+ "module": "CommonJS",
7
7
  "target": "es2022",
8
8
  "moduleResolution": "node",
9
+ "resolveJsonModule": true,
9
10
  "esModuleInterop": true,
10
11
  "allowSyntheticDefaultImports": true,
11
12
  "strict": true,
12
13
  "useUnknownInCatchVariables": false,
13
14
  "declaration": true,
15
+ "noEmitOnError": true,
16
+ "noUnusedLocals": false,
14
17
  "outDir": "lib"
15
- },
16
- "exclude": [
17
- "jest.config.ts"
18
- ]
18
+ }
19
19
  }
package/jest.config.ts DELETED
@@ -1,14 +0,0 @@
1
- import type { JestConfigWithTsJest } from 'ts-jest';
2
-
3
- const config: JestConfigWithTsJest = {
4
- verbose: true,
5
- collectCoverage: false,
6
- errorOnDeprecated: true,
7
- maxWorkers: 1,
8
- testMatch: [
9
- '**/__tests__/**/*.spec.ts'
10
- ],
11
- preset: 'ts-jest'
12
- };
13
-
14
- export default config;
package/lib/index.js DELETED
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var poweredFileSystem = require('./powered-file-system.js');
6
-
7
- // const pfs = new PoweredFileSystem();
8
- // export const test = pfs.test;
9
- // export const stat = pfs.stat;
10
- // export const chmod = pfs.chmod;
11
- // export const chown = pfs.chown;
12
- // export const symlink = pfs.symlink;
13
- // export const copy = pfs.copy;
14
- // export const rename = pfs.rename;
15
- // export const remove = pfs.remove;
16
- // export const read = pfs.read;
17
- // export const write = pfs.write;
18
- // export const append = pfs.append;
19
- // export const readdir = pfs.readdir;
20
- // export const mkdir = pfs.mkdir;
21
- const bitmask = poweredFileSystem.PoweredFileSystem.bitmask;
22
-
23
- exports.default = poweredFileSystem.PoweredFileSystem;
24
- exports.bitmask = bitmask;
@@ -1,90 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var fs = require('node:fs');
6
- var path = require('node:path');
7
-
8
- const { sep } = path;
9
- function chmod(src, mode) {
10
- const stat = fs.statSync(src);
11
- if (stat.isDirectory()) {
12
- const list = fs.readdirSync(src);
13
- for (const loc of list) {
14
- chmod(`${src}${sep}${loc}`, mode);
15
- }
16
- }
17
- fs.chmodSync(src, mode);
18
- }
19
- function chown(src, uid, gid) {
20
- const stat = fs.statSync(src);
21
- if (stat.isDirectory()) {
22
- const list = fs.readdirSync(src);
23
- for (const loc of list) {
24
- chown(`${src}${sep}${loc}`, uid, gid);
25
- }
26
- }
27
- fs.chownSync(src, uid, gid);
28
- }
29
- function copy(src, dir, umask) {
30
- const stat = fs.statSync(src);
31
- if (stat.isDirectory()) {
32
- const list = fs.readdirSync(src);
33
- const paths = src.split(sep);
34
- const loc = paths[paths.length - 1];
35
- const mode = 0o777 - umask;
36
- dir = `${dir}${sep}${loc}`;
37
- fs.mkdirSync(dir, mode);
38
- for (const loc of list) {
39
- copy(`${src}${sep}${loc}`, dir, umask);
40
- }
41
- }
42
- else {
43
- const loc = path.basename(src);
44
- const use = `${dir}${sep}${loc}`;
45
- fs.copyFileSync(src, use);
46
- }
47
- }
48
- function remove(src) {
49
- const stat = fs.statSync(src);
50
- if (stat.isDirectory()) {
51
- const list = fs.readdirSync(src);
52
- for (const loc of list) {
53
- remove(`${src}${sep}${loc}`);
54
- }
55
- fs.rmdirSync(src);
56
- }
57
- else {
58
- fs.unlinkSync(src);
59
- }
60
- }
61
- function mkdir(dir, umask) {
62
- const mode = 0o777 - umask;
63
- const cwd = process.cwd();
64
- let use = '';
65
- if (dir.indexOf(cwd) === 0) {
66
- use = cwd;
67
- dir = dir.substr(cwd.length);
68
- }
69
- const ways = dir.split(sep).slice(1);
70
- for (const loc of ways) {
71
- use += `${sep}${loc}`;
72
- try {
73
- fs.mkdirSync(use, { mode });
74
- }
75
- catch (err) {
76
- if (err.errno !== -17) {
77
- throw err;
78
- }
79
- }
80
- }
81
- }
82
- var recurseSync = {
83
- chmod,
84
- chown,
85
- copy,
86
- remove,
87
- mkdir
88
- };
89
-
90
- exports.default = recurseSync;
package/rollup.config.js DELETED
@@ -1,16 +0,0 @@
1
- import typescript from '@rollup/plugin-typescript';
2
- import { nodeResolve } from '@rollup/plugin-node-resolve';
3
-
4
- export default {
5
- input: './src/index.ts',
6
- output: {
7
- preserveModules: true,
8
- exports: 'named',
9
- dir: 'lib',
10
- format: 'cjs'
11
- },
12
- plugins: [
13
- nodeResolve(),
14
- typescript()
15
- ]
16
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes