Skip to content

Commit 1767513

Browse files
committed
homebrew fix
1 parent 43ad51d commit 1767513

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

dist/index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6768,20 +6768,22 @@ async function downloadCLI(osPlatform) {
67686768
case 'win32':
67696769
return await tc.extractZip(await tc.downloadTool(urls[osPlatform]));
67706770
case 'darwin':
6771-
// Use brew info --json to check if stackql is installed
6771+
// Check if stackql is already installed using brew list --formula
67726772
core.info(`Checking if stackql is already installed`);
67736773
try {
6774-
const brewInfo = execSync('brew info stackql --json', { encoding: 'utf-8' });
6775-
const brewInfoJson = JSON.parse(brewInfo);
6776-
if (brewInfoJson[0].installed.length > 0) {
6774+
const installedFormulas = execSync('brew list --formula', { encoding: 'utf-8' });
6775+
if (installedFormulas.includes('stackql')) {
67776776
core.info(`stackql is already installed.`);
67786777
const stackqlPath = execSync('which stackql', { encoding: 'utf-8' }).trim();
67796778
core.debug(`Stackql is located at: ${stackqlPath}`);
67806779
return path.dirname(stackqlPath); // Return the directory of the binary
6780+
} else {
6781+
core.info(`Installing stackql using Homebrew`);
6782+
execSync('brew install stackql', { stdio: 'inherit' });
67816783
}
67826784
} catch (error) {
6783-
core.info(`stackql is not installed, installing now...`);
6784-
execSync('brew install stackql', { stdio: 'inherit' });
6785+
core.info(`Error checking/installing stackql: ${error}`);
6786+
throw new Error(`Error checking/installing stackql: ${error}`);
67856787
}
67866788
const installedPath = execSync('which stackql', { encoding: 'utf-8' }).trim();
67876789
core.debug(`Stackql installed at: ${installedPath}`);

index.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,22 @@ async function downloadCLI(osPlatform) {
1919
case 'win32':
2020
return await tc.extractZip(await tc.downloadTool(urls[osPlatform]));
2121
case 'darwin':
22-
// Use brew info --json to check if stackql is installed
22+
// Check if stackql is already installed using brew list --formula
2323
core.info(`Checking if stackql is already installed`);
2424
try {
25-
const brewInfo = execSync('brew info stackql --json', { encoding: 'utf-8' });
26-
const brewInfoJson = JSON.parse(brewInfo);
27-
if (brewInfoJson[0].installed.length > 0) {
25+
const installedFormulas = execSync('brew list --formula', { encoding: 'utf-8' });
26+
if (installedFormulas.includes('stackql')) {
2827
core.info(`stackql is already installed.`);
2928
const stackqlPath = execSync('which stackql', { encoding: 'utf-8' }).trim();
3029
core.debug(`Stackql is located at: ${stackqlPath}`);
3130
return path.dirname(stackqlPath); // Return the directory of the binary
31+
} else {
32+
core.info(`Installing stackql using Homebrew`);
33+
execSync('brew install stackql', { stdio: 'inherit' });
3234
}
3335
} catch (error) {
34-
core.info(`stackql is not installed, installing now...`);
35-
execSync('brew install stackql', { stdio: 'inherit' });
36+
core.info(`Error checking/installing stackql: ${error}`);
37+
throw new Error(`Error checking/installing stackql: ${error}`);
3638
}
3739
const installedPath = execSync('which stackql', { encoding: 'utf-8' }).trim();
3840
core.debug(`Stackql installed at: ${installedPath}`);

0 commit comments

Comments
 (0)