Skip to content

Commit ed8ff36

Browse files
leohenongithub-actions[bot]
authored andcommitted
fix(vim): handle ETXTBSY on linux update
1 parent f8afe49 commit ed8ff36

2 files changed

Lines changed: 36 additions & 11 deletions

File tree

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ Then run:
1616
ocv
1717
```
1818

19+
## Update
20+
21+
```bash
22+
ocv update
23+
```
24+
1925
## Supported motions
2026

2127
`h` `j` `k` `l` `w` `b` `e` `W` `B` `E` `0` `^` `$` `gg` `G`
2228
`i` `I` `a` `A` `o` `O` `x` `dd` `dw` `cc` `cw` `S`
2329
`Ctrl+e` `Ctrl+y` `Ctrl+d` `Ctrl+u` `Ctrl+f` `Ctrl+b`
2430

25-
Missing something? Open a ticket.
31+
Missing something? Open an issue.

packages/opencode/src/cli/cmd/update.ts

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,38 @@ export const UpdateCommand = {
7373
prompts.log.info(`${Installation.VERSION}${version}`)
7474

7575
spinner.start("Downloading...")
76-
const { data, ext } = await download(version)
76+
const result = await download(version).catch((e) => e as Error)
77+
if (result instanceof Error) {
78+
spinner.stop("Download failed", 1)
79+
prompts.log.error(result.message)
80+
prompts.outro("Done")
81+
return
82+
}
7783
spinner.stop("Downloaded")
7884

79-
spinner.start("Installing...")
85+
const spinner2 = prompts.spinner()
86+
spinner2.start("Installing...")
8087
const tmp = await fs.mkdtemp(path.join(os.tmpdir(), "ocv-"))
81-
await extract(data, ext, tmp)
82-
83-
const bin = path.join(tmp, "opencode")
84-
const dest = process.execPath
85-
await fs.copyFile(bin, dest)
86-
await fs.chmod(dest, 0o755)
87-
await fs.rm(tmp, { recursive: true, force: true })
88-
spinner.stop("Installed")
88+
const err = await (async () => {
89+
try {
90+
await extract(result.data, result.ext, tmp)
91+
const bin = path.join(tmp, "opencode")
92+
const dest = process.execPath
93+
const staging = dest + ".tmp"
94+
await fs.copyFile(bin, staging)
95+
await fs.chmod(staging, 0o755)
96+
await fs.rename(staging, dest)
97+
} finally {
98+
await fs.rm(tmp, { recursive: true, force: true })
99+
}
100+
})().catch((e) => e as Error)
101+
if (err) {
102+
spinner2.stop("Install failed", 1)
103+
prompts.log.error(err.message)
104+
prompts.outro("Done")
105+
return
106+
}
107+
spinner2.stop("Installed")
89108

90109
prompts.log.success(`Updated to ${version}`)
91110
prompts.outro("Done")

0 commit comments

Comments
 (0)