Add 'fail_on_unmatched_files' input (#55)

This commit is contained in:
David Kramer
2020-06-24 23:11:41 -07:00
committed by GitHub
parent 9439581056
commit 4fb86a77e0
6 changed files with 54 additions and 17 deletions

View File

@ -13,6 +13,7 @@ export interface Config {
input_files?: string[];
input_draft?: boolean;
input_prerelease?: boolean;
input_fail_on_unmatched_files?: boolean;
}
export const releaseBody = (config: Config): string | undefined => {
@ -47,7 +48,8 @@ export const parseConfig = (env: Env): Config => {
input_body_path: env.INPUT_BODY_PATH,
input_files: parseInputFiles(env.INPUT_FILES || ""),
input_draft: env.INPUT_DRAFT === "true",
input_prerelease: env.INPUT_PRERELEASE == "true"
input_prerelease: env.INPUT_PRERELEASE == "true",
input_fail_on_unmatched_files: env.INPUT_FAIL_ON_UNMATCHED_FILES == "true"
};
};
@ -59,6 +61,16 @@ export const paths = (patterns: string[]): string[] => {
}, []);
};
export const unmatchedPatterns = (patterns: string[]): string[] => {
return patterns.reduce((acc: string[], pattern: string): string[] => {
return acc.concat(
glob.sync(pattern).filter(path => lstatSync(path).isFile()).length == 0
? [pattern]
: []
);
}, []);
};
export const isTag = (ref: string): boolean => {
return ref.startsWith("refs/tags/");
};