Skip to content

Commit

Permalink
update cert search
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenHodgson committed Oct 31, 2024
1 parent bb5e9d2 commit 02a8c0b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 23 deletions.
30 changes: 19 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30656,18 +30656,26 @@ const main = async () => {
main();
async function getCertificatePath(projectPath) {
let certificatePath = core.getInput(`certificate-path`) || `${projectPath}/**/*.pfx`;
const certificateGlobber = await glob.create(certificatePath);
const certificateFiles = await certificateGlobber.glob();
switch (certificateFiles.length) {
case 0:
throw new Error(`No certificate file found. Please set the 'certificate-path' input.`);
default:
if (certificateFiles.length > 1) {
core.warning(`More than one certificate file found, using the first one found:\n${certificateFiles.join(`\n`)}`);
}
certificatePath = certificateFiles[0];
core.info(`certificatePath: "${certificatePath}"`);
if (!certificatePath.endsWith(`**/*.pfx`)) {
certificatePath = path.join(certificatePath, `**/*.pfx`);
}
if (certificatePath.includes(`*`)) {
const certificateGlobber = await glob.create(certificatePath);
const certificateFiles = await certificateGlobber.glob();
core.info(`Found certificate files:`);
certificateFiles.forEach(file => core.info(` - "${file}"`));
if (certificateFiles.length === 0) {
throw new Error(`No certificate file found: "${certificatePath}"`);
}
certificatePath = certificateFiles[0];
}
try {
await fs.promises.access(certificatePath, fs.constants.R_OK);
}
catch (error) {
throw new Error(`Certificate file not found: "${certificatePath}"`);
}
await fs.promises.access(certificatePath, fs.constants.R_OK);
return certificatePath;
}
async function getCertificateThumbprint(certificatePath) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

29 changes: 18 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,25 @@ main();

async function getCertificatePath(projectPath: string): Promise<string> {
let certificatePath = core.getInput(`certificate-path`) || `${projectPath}/**/*.pfx`;
const certificateGlobber = await glob.create(certificatePath);
const certificateFiles = await certificateGlobber.glob();
switch (certificateFiles.length) {
case 0:
throw new Error(`No certificate file found. Please set the 'certificate-path' input.`);
default:
if (certificateFiles.length > 1) {
core.warning(`More than one certificate file found, using the first one found:\n${certificateFiles.join(`\n`)}`);
}
certificatePath = certificateFiles[0];
core.info(`certificatePath: "${certificatePath}"`);
if (!certificatePath.endsWith(`**/*.pfx`)) {
certificatePath = path.join(certificatePath, `**/*.pfx`);
}
if (certificatePath.includes(`*`)) {
const certificateGlobber = await glob.create(certificatePath);
const certificateFiles = await certificateGlobber.glob();
core.info(`Found certificate files:`);
certificateFiles.forEach(file => core.info(` - "${file}"`));
if (certificateFiles.length === 0) {
throw new Error(`No certificate file found: "${certificatePath}"`);
}
certificatePath = certificateFiles[0];
}
try {
await fs.promises.access(certificatePath, fs.constants.R_OK);
} catch (error) {
throw new Error(`Certificate file not found: "${certificatePath}"`);
}
await fs.promises.access(certificatePath, fs.constants.R_OK);
return certificatePath;
}

Expand Down

0 comments on commit 02a8c0b

Please sign in to comment.