-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding includes and excludes * Updating workflows
- Loading branch information
Showing
10 changed files
with
269 additions
and
119 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = crlf | ||
charset = utf-8 | ||
trim_trailing_whitespace = false | ||
insert_final_newline = false |
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,9 +1,10 @@ | ||
name: 📋 PR | ||
|
||
on: | ||
pull_request: {} | ||
workflow_dispatch: {} | ||
|
||
push: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
name: 📦🔍 Build Check | ||
|
11 changes: 4 additions & 7 deletions
11
.github/workflows/test script.yml → .github/workflows/test-script.yml
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { debug } from "@actions/core"; | ||
import { existsSync } from "fs"; | ||
|
||
export class Arguments { | ||
/** The folder to start the process of */ | ||
startFolder: string; | ||
/** The filename of the index files */ | ||
indexFilename: string; | ||
/** The content filename to add to indexes */ | ||
contentFilename: string; | ||
/** The patterns to include, addeds *.md by default */ | ||
includes: string[]; | ||
/** The patterns to exclude */ | ||
excludes: string[]; | ||
} | ||
|
||
export namespace Arguments { | ||
export function sanitize(args: Arguments): void { | ||
// Checks | ||
if (args.startFolder === "") { | ||
throw new Error("No folder specified"); | ||
} | ||
if (!existsSync(args.startFolder)) { | ||
throw new Error("Folder does not exist: " + args.startFolder); | ||
} | ||
|
||
if (args.indexFilename === "") { | ||
throw new Error("No filename specified for the indexes"); | ||
} | ||
|
||
if (!Array.isArray(args.includes)) { | ||
args.includes = []; | ||
} | ||
if (!Array.isArray(args.excludes)) { | ||
args.excludes = []; | ||
} | ||
|
||
// Add the content filename to the excludes | ||
if (args.contentFilename !== "") { | ||
args.excludes.push(args.contentFilename); | ||
} | ||
|
||
args.includes.push("*.md"); | ||
args.excludes.push(args.indexFilename, ".git", "node_modules"); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { PicomatchOptions, isMatch } from "picomatch"; | ||
|
||
export class FileFilter { | ||
private include: string[]; | ||
private exclude: string[]; | ||
private opts: PicomatchOptions; | ||
|
||
/** | ||
* Creates a new FileFilter. | ||
* @param include The patterns to include, addeds *.md by default. | ||
* @param exclude The patterns to exclude. | ||
*/ | ||
constructor(include: string[], exclude: string[]) { | ||
this.include = include; | ||
this.exclude = exclude; | ||
|
||
this.opts = { | ||
contains: true, | ||
}; | ||
} | ||
|
||
/** | ||
* Checks if the file is a match, and not excluded | ||
* @param filename The filename to check | ||
* @returns true if the file is a match, false otherwise | ||
*/ | ||
public isMatch(filename: string): boolean { | ||
return this.included(filename) && !this.excluded(filename); | ||
} | ||
|
||
/** | ||
* Checks if the file is included | ||
* @param filename The filepath to check | ||
* @returns true if the file is included, false otherwise | ||
*/ | ||
included(filename: string): boolean { | ||
return this.include.some((pattern) => | ||
isMatch(filename, pattern, this.opts) | ||
); | ||
} | ||
|
||
/** | ||
* Checks if the file is excluded | ||
* @param filename The filepath to check | ||
* @returns true if the file is excluded, false otherwise | ||
*/ | ||
excluded(filename: string): boolean { | ||
return this.exclude.some((pattern) => | ||
isMatch(filename, pattern, this.opts) | ||
); | ||
} | ||
} |
Oops, something went wrong.