-
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.
Allow Input and Output from Githubs env files.
- Loading branch information
1 parent
7ef9ed2
commit 3842cbe
Showing
8 changed files
with
158 additions
and
23 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
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,56 @@ | ||
export interface File { | ||
path: string | ||
file: string | ||
dir: string | ||
} | ||
|
||
export interface Mapping { | ||
runner: File | ||
container: File | ||
} | ||
|
||
export class FileMap { | ||
items: Map<string, Mapping> = new Map() | ||
containerTempDir: string | ||
|
||
constructor(containerTempDir: string) { | ||
this.containerTempDir = containerTempDir.endsWith('/') | ||
? containerTempDir | ||
: `${containerTempDir}/` | ||
} | ||
|
||
map<U>(callbackfn: (value: Mapping, key: string) => U): U[] { | ||
return Array.from(this.items.entries()).map(([key, value]) => | ||
callbackfn(value, key) | ||
) | ||
} | ||
|
||
pushRunnerPath(key: string, runnerPath: unknown): Mapping | undefined { | ||
if (typeof runnerPath === 'string' && runnerPath.length > 0) { | ||
const mapping = this.runnerPathToMapping(runnerPath) | ||
this.items.set(key, mapping) | ||
} | ||
|
||
return this.items.get(key) | ||
} | ||
|
||
protected runnerPathToMapping(runnerPath: string): Mapping { | ||
const runner = this.pathToFile(runnerPath) | ||
|
||
const container = { | ||
dir: this.containerTempDir, | ||
file: runner.file, | ||
path: this.containerTempDir + runner.file | ||
} | ||
|
||
return {runner, container} | ||
} | ||
|
||
protected pathToFile(path: string): File { | ||
const lastSlashIndex = path.lastIndexOf('/') | ||
const dir = path.substring(0, lastSlashIndex) | ||
const file = path.substring(lastSlashIndex + 1) | ||
|
||
return {path, dir, file} | ||
} | ||
} |
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