From 595226067cef4d3bb0b356668ddc9f6cf2b994b7 Mon Sep 17 00:00:00 2001 From: alexesprit Date: Sun, 3 Jan 2021 23:06:31 +0300 Subject: [PATCH] Add option to allow patterns to match hidden files --- README.md | 1 + action.yml | 5 +++++ src/util.ts | 12 +++++++++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8dd2407..8742640 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,7 @@ See the `fast-glob` [documentation][glob-docs] for glob syntax. #### Optional inputs - `branch`: branch to push changes (the default branch is used if no `branch` is specified) +- `allow-dot`: allow glob patterns to match entries that begin with a period (`false` by default) - `allow-removing`: allow to remove file if local copy is missing (`false` by default) diff --git a/action.yml b/action.yml index fb2d4a2..9f8721c 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,11 @@ inputs: description: Branch name requried: false + allow-dot: + description: Allow glob patterns to match entries that begin with a period + default: false + required: false + allow-removing: desciption: Allow to remove file default: false diff --git a/src/util.ts b/src/util.ts index 3a813fb..a55ac71 100644 --- a/src/util.ts +++ b/src/util.ts @@ -22,7 +22,13 @@ export function getBooleanInput(name: string, options?: InputOptions): boolean { export function getPathsToUpdate(): string[] { const rawPaths = getInput('file-path'); - return flatten(rawPaths.split(/\r?\n/).map(expandPathPattern)); + const allowDot = getBooleanInput('allow-dot'); + + return flatten( + rawPaths.split(/\r?\n/).map((path) => { + return expandPathPattern(path, { dot: allowDot }); + }) + ); } export function getActionOptions(): UpdaterOptions { @@ -37,11 +43,11 @@ export function isNotNull(arg: T): arg is Exclude { return arg !== null; } -function expandPathPattern(path: string): string[] { +function expandPathPattern(path: string, { dot = false }): string[] { const pathPattern = path.trim(); if (isDynamicPattern(pathPattern)) { - return globSync(pathPattern); + return globSync(pathPattern, { dot }); } return [pathPattern];