@kawalir/extension-node 0.4.0 → 0.6.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/CHANGELOG.md CHANGED
@@ -1 +1 @@
1
- Declare dependency types
1
+ New methods Folder.testExistence and Folder.list
@@ -1,4 +1,5 @@
1
- import { FileFunctions } from "@kawalir/extension-node/Core/Functions";
1
+ import { FileFunctions as FF } from "@kawalir/extension-node/Core/Functions";
2
+ import { Path, FileSystem } from "@kawalir/extension-node/External";
2
3
  import { TextFile } from "./TextFile";
3
4
 
4
5
  export class Folder {
@@ -6,12 +7,22 @@ export class Folder {
6
7
 
7
8
  public getFile = (name: string) => new TextFile(this.getPath(name));
8
9
 
10
+ public list = () =>
11
+ FileSystem.readdirSync(this.path, {
12
+ recursive: true,
13
+ encoding: "utf8",
14
+ }).map((p) => this.getPath(p));
15
+
9
16
  public getSubFolder = (relativePath: string) =>
10
17
  new Folder(this.getPath(relativePath));
11
18
 
12
19
  public getPath = (relative: string) => Path.join(this.path, relative);
13
20
 
14
- public ensure = () => FileFunctions.Folder.ensure(this.path);
21
+ public ensure = () => FF.Folder.ensure(this.path);
22
+
23
+ public testExistence = () => FF.Folder.testExistence(this.path);
24
+
25
+ public delete = () => FF.Folder.delete(this.path);
15
26
 
16
27
  public get parent(): Folder {
17
28
  return new Folder(Path.dirname(this.path));
@@ -1,3 +1,4 @@
1
+ import { Path, FileSystem as FS } from "@kawalir/extension-node/External";
1
2
  import { BasicFunctions as BF } from "../Basic";
2
3
 
3
4
  export class FolderFunctions {
@@ -12,11 +13,17 @@ export class FolderFunctions {
12
13
  };
13
14
 
14
15
  public static create = (path: string) => {
15
- FileSystem.mkdirSync(path, {
16
+ FS.mkdirSync(path, {
16
17
  recursive: true,
17
18
  });
18
19
  };
19
20
 
21
+ public static delete = (path: string) =>
22
+ FS.rmSync(path, {
23
+ force: true,
24
+ recursive: true,
25
+ });
26
+
20
27
  public static testExistence = (path: string) =>
21
28
  BF.testExistence(path, (stats) => stats.isDirectory());
22
29
  }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "Node",
8
8
  "Node Extension"
9
9
  ],
10
- "version": "0.4.0",
10
+ "version": "0.6.0",
11
11
  "author": "Denis Mijatovic",
12
12
  "license": "MIT",
13
13
  "type": "commonjs",
package/tsconfig.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "compilerOptions": {
4
4
  // File Layout
5
5
  // "rootDir": "",
6
- // "outDir": "",
6
+ "outDir": "./dist",
7
7
 
8
8
  // Environment Settings
9
9
  // See also https://aka.ms/tsconfig/module