Skip to content

Commit

Permalink
fix: add defaults for the missing actions options
Browse files Browse the repository at this point in the history
Signed-off-by: Amin Yahyaabadi <[email protected]>
  • Loading branch information
aminya committed Apr 3, 2024
1 parent cfc6f5e commit 969118a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
18 changes: 9 additions & 9 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions src/opts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export type Opts = {
export function parseOpts(args: string[]): mri.Argv<Opts> {
const opts = mri<Opts>(args, {
default: {
"cache-map": getInput("cache-map"),
"scratch-dir": getInput("scratch-dir"),
"skip-extraction": getInput("skip-extraction") === "true",
"cache-map": getInput("cache-map") || "{}",
"scratch-dir": getInput("scratch-dir") || "scratch",
"skip-extraction": (getInput("skip-extraction") || "false") === "true",
"extract": process.env[`STATE_POST`] !== undefined,
"help": false,
},
string: ["cache-map", "scratch-dir", "cache-source", "cache-target"],
boolean: ["skip-extraction", "help", "extract"],
Expand Down Expand Up @@ -74,10 +75,10 @@ export function getTargetPath(cacheOptions: CacheOptions): TargetPath {
return cacheOptions;
} else {
// object is provided
try {
if ("target" in cacheOptions) {
return cacheOptions.target;
} catch (e) {
throw new Error(`Expected the 'target' key in the cache options, got:\n${cacheOptions}\n${e}`);
} else {
throw new Error(`Expected the 'target' key in the cache options, got:\n${cacheOptions}`);
}
}
}
Expand Down

0 comments on commit 969118a

Please sign in to comment.