Skip to content

Commit

Permalink
fix: 🐞 fix VSCode installation detection in macOS
Browse files Browse the repository at this point in the history
fix VSCode installation detection in macOS
  • Loading branch information
tal-rofe committed Feb 15, 2023
1 parent 7b9c7f6 commit a24e92a
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/helpers/required-software.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import util from 'node:util';
import { execFile } from 'node:child_process';

import envinfo from 'envinfo';

const asyncExecFile = util.promisify(execFile);

export const getNodeJsVersion = async () => {
const nodeJsInfo = await envinfo.helpers.getNodeInfo();

Expand All @@ -19,7 +24,20 @@ export const ensureRequiredSoftware = async () => {
};

export const isVsCodeInstalled = async () => {
const vsCodeInfo = await envinfo.helpers.getVSCodeInfo();
// * "envinfo" library relies on the fact that "code" command will be availble, which isn't neccessarily on macOS
if (process.platform !== 'darwin') {
const vsCodeInfo = await envinfo.helpers.getVSCodeInfo();

return vsCodeInfo[1] !== 'Not Found';
}

const vsCodeFolderOutput = await asyncExecFile('/usr/bin/mdfind', [
'kMDItemCFBundleIdentifier = "com.microsoft.VSCode"',
]);

if (vsCodeFolderOutput.stderr) {
return false;
}

return vsCodeInfo[1] !== 'Not Found';
return true;
};

0 comments on commit a24e92a

Please sign in to comment.