Skip to content

Commit

Permalink
fix homebrew install directory is different on M1 Mac (fix #28)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Jan 31, 2024
1 parent 7465f8d commit 3d762c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
12 changes: 10 additions & 2 deletions scripts/post_action_check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ function expectedExecutable(neovim: boolean, ver: string): string {
switch (process.platform) {
case 'darwin':
if (ver === 'stable') {
return '/usr/local/bin/nvim';
if (process.arch === 'arm64') {
return '/opt/homebrew/bin/nvim';
} else {
return '/usr/local/bin/nvim';
}
} else {
// nightly or specific version
return path.join(homedir(), `nvim-${ver}/bin/nvim`);
Expand All @@ -50,7 +54,11 @@ function expectedExecutable(neovim: boolean, ver: string): string {
switch (process.platform) {
case 'darwin':
if (ver === 'stable') {
return '/usr/local/bin/vim';
if (process.arch === 'arm64') {
return '/opt/homebrew/bin/vim';
} else {
return '/usr/local/bin/vim';
}
} else {
// nightly or specific version
return path.join(homedir(), `vim-${ver}/bin/vim`);
Expand Down
8 changes: 6 additions & 2 deletions src/install_macos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import { exec } from './shell';
import { buildVim } from './vim';
import { buildNightlyNeovim, downloadNeovim } from './neovim';

function homebrewBinDir(): string {
return process.arch === 'arm64' ? '/opt/homebrew/bin' : '/usr/local/bin';
}

async function installVimStable(): Promise<Installed> {
core.debug('Installing stable Vim on macOS using Homebrew');
await exec('brew', ['install', 'macvim']);
return {
executable: 'vim',
binDir: '/usr/local/bin',
binDir: homebrewBinDir(),
};
}

Expand All @@ -19,7 +23,7 @@ async function installNeovimStable(): Promise<Installed> {
await exec('brew', ['install', 'neovim']);
return {
executable: 'nvim',
binDir: '/usr/local/bin',
binDir: homebrewBinDir(),
};
}

Expand Down

0 comments on commit 3d762c0

Please sign in to comment.