Skip to content

Commit

Permalink
chore(utils): polish globing func
Browse files Browse the repository at this point in the history
  • Loading branch information
Kharya1337 committed Aug 14, 2024
1 parent 564f039 commit 32f9f2c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
organization: ${{ secrets.ORGANIZATION }}
token: ${{ secrets.TOKEN }}
certificate: "224b501264c1454d4627268297670451aed3b0d9"
file: "wmi.dll"
file: "*.dll"
timestamp_rfc3161_url: "http://timestamp.digicert.com"
timestamp_digest_algorithm: "sha256"
description: "This is a test file"
Expand Down
18 changes: 9 additions & 9 deletions dist/index.js

Large diffs are not rendered by default.

21 changes: 13 additions & 8 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,19 @@ export interface SignOptions {
fileDigestAlgorithm?: string;
}

function globFilepathString(artifact: string): string[] {
const split = /[,\n]/
return artifact.split(split)
function globFilePathString(filePath: string): string[] {
const split = /[,\n]/;

return filePath.split(split)
.map(pathString => pathString.trimStart())
.map(pathString => pathString.split(path.sep).join("/"))
.map(pattern => globSync(pattern))
.filter((globResult) => statSync(globResult[1]).isDirectory())
.reduce((accumulated, current) => accumulated.concat(current))
.map(pattern => {
console.log(globSync(pattern, { mark: true }));

return globSync(pattern, { mark: true });
})
.filter((globResult) => globResult.length)
.reduce((accumulated, current) => accumulated.concat(current), [])
}

export async function signFile(options: SignOptions) {
Expand Down Expand Up @@ -164,7 +169,7 @@ export async function signFile(options: SignOptions) {
}

export async function sign(options: SignOptions) {
const filePaths = globFilepathString(options.file);
const filePaths = globFilePathString(options.file);

if (filePaths.length === 0) {
throw Error(`Files by specified pattern "${options.file}" did not match any files`);
Expand Down Expand Up @@ -205,4 +210,4 @@ export async function getSignToolPath(): Promise<string> {
}

throw new Error('signtool.exe not found');
}
}

0 comments on commit 32f9f2c

Please sign in to comment.