@aminzer/traverse-directory 1.0.0 → 1.1.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.
package/README.md CHANGED
@@ -29,7 +29,9 @@ await traverseDirectory('/path/to/directory', ({ isFile, relativePath }) => {
29
29
  `traverseDirectory` recursively iterates over the contents of a directory.
30
30
 
31
31
  ```typescript
32
- traverseDirectory(dirPath, onEachChild);
32
+ import { directoryExists } from '@aminzer/traverse-directory';
33
+
34
+ await traverseDirectory(dirPath, onEachChild);
33
35
  ```
34
36
 
35
37
  ##### Parameters
@@ -63,3 +65,24 @@ Instance properties:
63
65
  * `size` (`number`) - size of file in bytes, `0` for directories.
64
66
  * `isFile` (`boolean`) - `true` if entry is file.
65
67
  * `isDirectory` (`boolean`) - `true` if entry is directory.
68
+
69
+
70
+ **directoryExists**
71
+
72
+ ##### Overview
73
+
74
+ `directoryExists` is an async function that checks if a given path exists and corresponds to a directory.
75
+
76
+ ```typescript
77
+ import { directoryExists } from '@aminzer/traverse-directory';
78
+
79
+ const exists = await directoryExists('/path/to/directory');
80
+ ```
81
+
82
+ ##### Parameters
83
+
84
+ * `dirPath` (`string`, required) - path to the directory to check.
85
+
86
+ ##### Return value
87
+
88
+ `Promise<boolean>` that resolves to `true` if the directory exists, or `false` otherwise.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { default as traverseDirectory } from './traverseDirectory';
2
+ export { directoryExists } from './utils/fs';
2
3
  export { FsEntry } from './models';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as traverseDirectory } from './traverseDirectory';
2
+ export { directoryExists } from './utils/fs';
2
3
  export { FsEntry } from './models';
3
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
@@ -1,7 +1,7 @@
1
- import { directoryExist } from '../utils/fs';
1
+ import { directoryExists } from '../utils/fs';
2
2
  import traverseDirectoryRecursive from './traverseDirectoryRecursive';
3
3
  const traverseDirectory = async (dirPath, onEachChild) => {
4
- if (!(await directoryExist(dirPath))) {
4
+ if (!(await directoryExists(dirPath))) {
5
5
  throw new Error(`Directory "${dirPath}" does not exist`);
6
6
  }
7
7
  await traverseDirectoryRecursive(dirPath, null, onEachChild);
@@ -1 +1 @@
1
- {"version":3,"file":"traverseDirectory.js","sourceRoot":"","sources":["../../src/traverseDirectory/traverseDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,0BAA0B,MAAM,8BAA8B,CAAC;AAGtE,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAAe,EAAE,WAAwB,EAAiB,EAAE;IAC3F,IAAI,CAAC,CAAC,MAAM,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CAAC,cAAc,OAAO,kBAAkB,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,0BAA0B,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
1
+ {"version":3,"file":"traverseDirectory.js","sourceRoot":"","sources":["../../src/traverseDirectory/traverseDirectory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,0BAA0B,MAAM,8BAA8B,CAAC;AAGtE,MAAM,iBAAiB,GAAG,KAAK,EAAE,OAAe,EAAE,WAAwB,EAAiB,EAAE;IAC3F,IAAI,CAAC,CAAC,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,cAAc,OAAO,kBAAkB,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,0BAA0B,CAAC,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,25 +1,25 @@
1
1
  import assert from 'node:assert';
2
2
  import { join } from 'node:path';
3
3
  import { describe, it } from 'node:test';
4
- import directoryExist from '../directoryExist';
5
- describe('utils > fs > directoryExist', () => {
4
+ import directoryExists from '../directoryExists';
5
+ describe('utils > fs > directoryExists', () => {
6
6
  describe('when path does not exist', () => {
7
7
  const invalidPath = join(import.meta.dirname, 'invalid/path');
8
8
  it('returns false', async () => {
9
- assert.strictEqual(await directoryExist(invalidPath), false);
9
+ assert.strictEqual(await directoryExists(invalidPath), false);
10
10
  });
11
11
  });
12
12
  describe('when path corresponds to file', () => {
13
13
  const filePath = import.meta.filename;
14
14
  it('returns false', async () => {
15
- assert.strictEqual(await directoryExist(filePath), false);
15
+ assert.strictEqual(await directoryExists(filePath), false);
16
16
  });
17
17
  });
18
18
  describe('when path corresponds to directory', () => {
19
19
  const dirPath = import.meta.dirname;
20
20
  it('returns true', async () => {
21
- assert.strictEqual(await directoryExist(dirPath), true);
21
+ assert.strictEqual(await directoryExists(dirPath), true);
22
22
  });
23
23
  });
24
24
  });
25
- //# sourceMappingURL=directoryExist.test.js.map
25
+ //# sourceMappingURL=directoryExists.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directoryExists.test.js","sourceRoot":"","sources":["../../../../src/utils/fs/__tests__/directoryExists.test.ts"],"names":[],"mappings":"AAAA,OAAO,MA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1
1
  import { stat } from 'node:fs/promises';
2
- const directoryExist = async (path) => {
2
+ const directoryExists = async (path) => {
3
3
  try {
4
4
  const stats = await stat(path);
5
5
  return stats.isDirectory();
@@ -8,5 +8,5 @@ const directoryExist = async (path) => {
8
8
  return false;
9
9
  }
10
10
  };
11
- export default directoryExist;
12
- //# sourceMappingURL=directoryExist.js.map
11
+ export default directoryExists;
12
+ //# sourceMappingURL=directoryExists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directoryExists.js","sourceRoot":"","sources":["../../../src/utils/fs/directoryExists.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,MAAM,eAAe,GAAG,KAAK,EAAE,IAAY,EAAoB,EAAE;IAC/D,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1 +1 @@
1
- export { default as directoryExist } from './directoryExist';
1
+ export { default as directoryExists } from './directoryExists';
@@ -1,2 +1,2 @@
1
- export { default as directoryExist } from './directoryExist';
1
+ export { default as directoryExists } from './directoryExists';
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/fs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/fs/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aminzer/traverse-directory",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Utility for directory child entries recursive iteration",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1 +0,0 @@
1
- {"version":3,"file":"directoryExist.test.js","sourceRoot":"","sources":["../../../../src/utils/fs/__tests__/directoryExist.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAE/C,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACxC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAE9D,EAAE,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE;YAC7B,MAAM,CAAC,WAAW,CAAC,MAAM,cAAc,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,+BAA+B,EAAE,GAAG,EAAE;QAC7C,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QAEtC,EAAE,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE;YAC7B,MAAM,CAAC,WAAW,CAAC,MAAM,cAAc,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;QAC5D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAClD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;QAEpC,EAAE,CAAC,cAAc,EAAE,KAAK,IAAI,EAAE;YAC5B,MAAM,CAAC,WAAW,CAAC,MAAM,cAAc,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- declare const directoryExist: (path: string) => Promise<boolean>;
2
- export default directoryExist;
@@ -1 +0,0 @@
1
- {"version":3,"file":"directoryExist.js","sourceRoot":"","sources":["../../../src/utils/fs/directoryExist.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,MAAM,cAAc,GAAG,KAAK,EAAE,IAAY,EAAoB,EAAE;IAC9D,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}