@lvce-editor/shared-process 0.14.9 → 0.14.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/shared-process",
3
- "version": "0.14.9",
3
+ "version": "0.14.10",
4
4
  "description": "Utility package for @lvce-editor/server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -17,9 +17,9 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@babel/code-frame": "^7.21.4",
20
- "@lvce-editor/extension-host": "0.14.9",
21
- "@lvce-editor/extension-host-helper-process": "0.14.9",
22
- "@lvce-editor/pty-host": "0.14.9",
20
+ "@lvce-editor/extension-host": "0.14.10",
21
+ "@lvce-editor/extension-host-helper-process": "0.14.10",
22
+ "@lvce-editor/pty-host": "0.14.10",
23
23
  "debug": "^4.3.4",
24
24
  "execa": "^7.1.1",
25
25
  "exit-hook": "^3.2.0",
@@ -1,7 +1,7 @@
1
1
  import { spawn } from 'node:child_process'
2
2
  import { rename } from 'node:fs/promises'
3
3
  import { tmpdir } from 'node:os'
4
- import { join } from 'node:path'
4
+ import { basename, dirname, join } from 'node:path'
5
5
  import * as Assert from '../Assert/Assert.js'
6
6
  import * as CompareVersion from '../CompareVersion/CompareVersion.js'
7
7
  import * as Download from '../Download/Download.js'
@@ -53,9 +53,18 @@ const getAppImagePath = () => {
53
53
  return process.env.APPIMAGE
54
54
  }
55
55
 
56
- const installNewAppImage = async (appImageFile, downloadPath) => {
56
+ const installNewAppImage = async (currentAppImageFile, downloadPath) => {
57
57
  try {
58
- await rename(downloadPath, appImageFile)
58
+ const currentFileName = basename(currentAppImageFile)
59
+ const newFileName = basename(downloadPath)
60
+ if (currentFileName === newFileName) {
61
+ await rename(downloadPath, currentAppImageFile)
62
+ return currentAppImageFile
63
+ }
64
+ const destinationFolder = dirname(currentAppImageFile)
65
+ const destinationPath = join(destinationFolder, newFileName)
66
+ await rename(downloadPath, destinationPath)
67
+ return destinationPath
59
68
  } catch (error) {
60
69
  // @ts-ignore
61
70
  throw new VError(error, `Failed to rename AppImage file`)
@@ -70,13 +79,13 @@ const restart = (downloadPath) => {
70
79
  export const installAndRestart = async (downloadPath) => {
71
80
  try {
72
81
  Assert.string(downloadPath)
73
- const appImageFile = getAppImagePath()
74
- if (!appImageFile) {
82
+ const currentAppImageFile = getAppImagePath()
83
+ if (!currentAppImageFile) {
75
84
  throw new Error(`AppImage path not found`)
76
85
  }
77
86
  await MakeExecutable.makeExecutable(downloadPath)
78
- await installNewAppImage(appImageFile, downloadPath)
79
- await restart(downloadPath)
87
+ const installedPath = await installNewAppImage(currentAppImageFile, downloadPath)
88
+ await restart(installedPath)
80
89
  } catch (error) {
81
90
  // @ts-ignore
82
91
  throw new VError(error, `Failed to install AppImage update`)