Skip to content

Commit

Permalink
macOS で run コマンドが失敗する問題を修正。
Browse files Browse the repository at this point in the history
  • Loading branch information
mikoto2000 committed Dec 1, 2024
1 parent 587ced1 commit c3805d2
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ WATCH_SRC := ./main.go \
./devcontainer/readConfigurationResult.go \
./devcontainer/upCommandResult.go \
./docker/docker.go \
./docker/dockerVimArgs_darwin_arm64.go \
./docker/dockerVimArgs_linux_amd64.go \
./docker/dockerVimArgs_windows_amd64.go \
./docker/dockerPsResult.go \
./dockercompose/dockerCompose.go \
./dockercompose/dockerComposePsResult.go \
Expand Down
11 changes: 2 additions & 9 deletions docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func Run(args []string, vimFilePath string, cdrPath string, configDirForDocker s

// コンテナへ appimage を転送して実行権限を追加
// `docker cp <os.UserCacheDir/devcontainer.vim/Vim-AppImage> <dockerrun 時に標準出力に表示される CONTAINER ID>:/`
err = Cp("AppImage", vimFilePath, containerID, "/")
err = Cp("vim", vimFilePath, containerID, "/")
if err != nil {
return err
}
Expand Down Expand Up @@ -121,14 +121,7 @@ func Run(args []string, vimFilePath string, cdrPath string, configDirForDocker s
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel()

dockerVimArgs := []string{
"exec",
"-it",
containerID,
"sh",
"-c",
"cd ~; /" + vimFileName + " --appimage-extract > /dev/null; cd -; ~/squashfs-root/AppRun --cmd \"let g:devcontainer_vim = v:true\" -S /SendToTcp.vim -S /vimrc",
}
dockerVimArgs := DockerVimArgs(containerID, vimFileName)
fmt.Printf("Start vim: `%s \"%s\"`\n", containerCommand, strings.Join(dockerVimArgs, "\" \""))
dockerExec := exec.CommandContext(ctx, containerCommand, dockerVimArgs...)
dockerExec.Stdin = os.Stdin
Expand Down
13 changes: 13 additions & 0 deletions docker/dockerVimArgs_darwin_arm64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build darwin && arm64

package docker

func DockerVimArgs(containerID string, vimFileName string) []string {
return []string{
"exec",
"-it",
containerID,
"sh",
"-c",
"cd /; tar zxf ./" + vimFileName + " -C ~/ > /dev/null; cd ~; sudo rm -rf ~/vim-static; mv $(ls -d ~/vim-*-aarch64) ~/vim-static;~/vim-static/AppRun --cmd \"let g:devcontainer_vim = v:true\" -S /SendToTcp.vim -S /vimrc"}
}
13 changes: 13 additions & 0 deletions docker/dockerVimArgs_linux_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build linux && amd64

package docker

func DockerVimArgs(containerID string, vimFileName string) []string {
return []string{
"exec",
"-it",
containerID,
"sh",
"-c",
"cd ~; /" + vimFileName + " --appimage-extract > /dev/null; cd -; ~/squashfs-root/AppRun --cmd \"let g:devcontainer_vim = v:true\" -S /SendToTcp.vim -S /vimrc"}
}
13 changes: 13 additions & 0 deletions docker/dockerVimArgs_windows_amd64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//go:build windows && amd64

package docker

func DockerVimArgs(containerID string, vimFileName string) []string {
return []string{
"exec",
"-it",
containerID,
"sh",
"-c",
"cd ~; /" + vimFileName + " --appimage-extract > /dev/null; cd -; ~/squashfs-root/AppRun --cmd \"let g:devcontainer_vim = v:true\" -S /SendToTcp.vim -S /vimrc"}
}

0 comments on commit c3805d2

Please sign in to comment.