-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: detect CPU type and if Rosetta is installed on start
- Loading branch information
1 parent
cf7b0e0
commit c08264b
Showing
9 changed files
with
77 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { execAsync } from './execAsync'; | ||
|
||
const hasIntelCpu = async (): Promise<boolean> => { | ||
try { | ||
await execAsync( | ||
'/usr/sbin/sysctl -n machdep.cpu.brand_string | grep -o "Intel"' | ||
); | ||
|
||
return true; | ||
} catch { | ||
return false; | ||
} | ||
}; | ||
|
||
export const checkCpu = async (): Promise<void> => { | ||
const intelCpu = await hasIntelCpu(); | ||
|
||
if (intelCpu) { | ||
throw new Error('You need a Mac with an ARM processor to run this tool.'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import inquirer from 'inquirer'; | ||
|
||
import { installRosetta, isRosettaInstalled } from './installRosetta'; | ||
|
||
export const checkRosetta = async (): Promise<void> => { | ||
const rosettaInstalled = await isRosettaInstalled(); | ||
|
||
if (rosettaInstalled) { | ||
return; | ||
} | ||
|
||
const { install }: { install: boolean } = await inquirer.prompt([ | ||
{ | ||
type: 'confirm', | ||
name: 'install', | ||
message: 'Rosetta 2 is not found on this Mac, do you want to install it?' | ||
} | ||
]); | ||
|
||
if (install) { | ||
return installRosetta(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { exec } from 'child_process'; | ||
import { promisify } from 'util'; | ||
|
||
export const execAsync = promisify(exec); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const logError = (err: Error): void => | ||
console.error('❌ Error:', err?.message); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters