-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,923 additions
and
1,847 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { normalize, basename } from "path"; | ||
|
||
export abstract class AFilesystemNode { | ||
public readonly absolutePath: string; | ||
public readonly relativePath: string; | ||
public readonly name: string; | ||
public readonly extension: string; | ||
public readonly absolutePath: string; | ||
public readonly relativePath: string; | ||
public readonly name: string; | ||
public readonly extension: string; | ||
|
||
constructor(relativePath: string) { | ||
this.relativePath = normalize(`./${relativePath}`); | ||
this.name = basename(relativePath).replace(/\.[^.]+$/, ""); | ||
this.extension = (relativePath.match(/\.([^.]+)$/) ?? [])[1]; | ||
} | ||
constructor(relativePath: string) { | ||
this.relativePath = normalize(`./${relativePath}`); | ||
this.name = basename(relativePath).replace(/\.[^.]+$/, ""); | ||
this.extension = (relativePath.match(/\.([^.]+)$/) ?? [])[1]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { AFilesystemNode } from "./AFilesystemNode"; | ||
|
||
export class Directory extends AFilesystemNode { | ||
public readonly fileNodes: AFilesystemNode[]; | ||
public readonly fileNodes: AFilesystemNode[]; | ||
|
||
constructor(relativePath: string, fileNodes: AFilesystemNode[] = []) { | ||
super(relativePath); | ||
constructor(relativePath: string, fileNodes: AFilesystemNode[] = []) { | ||
super(relativePath); | ||
|
||
this.fileNodes = fileNodes; | ||
} | ||
this.fileNodes = fileNodes; | ||
} | ||
|
||
public traverse( | ||
itemCb: (fileNode: AFilesystemNode) => void, | ||
recursive: boolean = false | ||
) { | ||
this.fileNodes.forEach((fileNode: AFilesystemNode) => { | ||
fileNode instanceof Directory | ||
? recursive && fileNode.traverse(itemCb, recursive) | ||
: itemCb(fileNode); | ||
}); | ||
} | ||
public traverse( | ||
itemCb: (fileNode: AFilesystemNode) => void, | ||
recursive: boolean = false | ||
) { | ||
this.fileNodes.forEach((fileNode: AFilesystemNode) => { | ||
fileNode instanceof Directory | ||
? recursive && fileNode.traverse(itemCb, recursive) | ||
: itemCb(fileNode); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { AFilesystemNode } from "./AFilesystemNode"; | ||
|
||
export class File extends AFilesystemNode { | ||
public readonly contents?: Buffer | string; | ||
public readonly contents?: Buffer | string; | ||
|
||
constructor(relativePath: string, contents?: Buffer | string) { | ||
super(relativePath); | ||
constructor(relativePath: string, contents?: Buffer | string) { | ||
super(relativePath); | ||
|
||
this.contents = contents; | ||
} | ||
this.contents = contents; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.