Skip to content

Commit

Permalink
Add option to allow patterns to match hidden files
Browse files Browse the repository at this point in the history
  • Loading branch information
alexesprit committed Jan 3, 2021
1 parent 5bd27c3 commit 5952260
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -37,11 +43,11 @@ export function isNotNull<T>(arg: T): arg is Exclude<T, null> {
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];
Expand Down

0 comments on commit 5952260

Please sign in to comment.