@lvce-editor/shared-process 0.14.11 → 0.14.13

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.11",
3
+ "version": "0.14.13",
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.11",
21
- "@lvce-editor/extension-host-helper-process": "0.14.11",
22
- "@lvce-editor/pty-host": "0.14.11",
20
+ "@lvce-editor/extension-host": "0.14.13",
21
+ "@lvce-editor/extension-host-helper-process": "0.14.13",
22
+ "@lvce-editor/pty-host": "0.14.13",
23
23
  "debug": "^4.3.4",
24
24
  "execa": "^7.1.1",
25
25
  "exit-hook": "^3.2.0",
@@ -1,14 +1,15 @@
1
- import { spawn } from 'node:child_process'
2
1
  import { rename } from 'node:fs/promises'
3
2
  import { tmpdir } from 'node:os'
4
- import { basename, dirname, join } from 'node:path'
3
+ import { join } from 'node:path'
5
4
  import * as Assert from '../Assert/Assert.js'
6
5
  import * as CompareVersion from '../CompareVersion/CompareVersion.js'
7
6
  import * as Download from '../Download/Download.js'
8
7
  import * as GetAppImageDownloadUrl from '../GetAppImageDownloadUrl/GetAppImageDownloadUrl.js'
8
+ import * as GetAppImagePath from '../GetAppImagePath/GetAppImagePath.js'
9
9
  import * as GetLatestReleaseVersion from '../GetLatestReleaseVersion/GetLatestReleaseVersion.js'
10
10
  import * as MakeExecutable from '../MakeExecutable/MakeExecutable.js'
11
11
  import * as Platform from '../Platform/Platform.js'
12
+ import * as Restart from '../Restart/Restart.js'
12
13
  import { VError } from '../VError/VError.js'
13
14
 
14
15
  const getOutfilePath = (version) => {
@@ -45,43 +46,26 @@ export const checkForUpdatesAndNotify = async () => {
45
46
  }
46
47
  }
47
48
 
48
- const getAppImagePath = () => {
49
- return process.env.APPIMAGE
50
- }
51
-
52
49
  const installNewAppImage = async (currentAppImageFile, downloadPath) => {
53
50
  try {
54
- const currentFileName = basename(currentAppImageFile)
55
- const newFileName = basename(downloadPath)
56
- if (currentFileName === newFileName) {
57
- await rename(downloadPath, currentAppImageFile)
58
- return currentAppImageFile
59
- }
60
- const destinationFolder = dirname(currentAppImageFile)
61
- const destinationPath = join(destinationFolder, newFileName)
62
- await rename(downloadPath, destinationPath)
63
- return destinationPath
51
+ await rename(downloadPath, currentAppImageFile)
52
+ return currentAppImageFile
64
53
  } catch (error) {
65
54
  // @ts-ignore
66
55
  throw new VError(error, `Failed to rename AppImage file`)
67
56
  }
68
57
  }
69
58
 
70
- const restart = (downloadPath) => {
71
- // TODO handle errors
72
- spawn(downloadPath, { stdio: 'inherit' })
73
- }
74
-
75
59
  export const installAndRestart = async (downloadPath) => {
76
60
  try {
77
61
  Assert.string(downloadPath)
78
- const currentAppImageFile = getAppImagePath()
62
+ const currentAppImageFile = GetAppImagePath.getAppImagePath()
79
63
  if (!currentAppImageFile) {
80
64
  throw new Error(`AppImage path not found`)
81
65
  }
82
66
  await MakeExecutable.makeExecutable(downloadPath)
83
67
  const installedPath = await installNewAppImage(currentAppImageFile, downloadPath)
84
- await restart(installedPath)
68
+ await Restart.restart(installedPath)
85
69
  } catch (error) {
86
70
  // @ts-ignore
87
71
  throw new VError(error, `Failed to install AppImage update`)
@@ -0,0 +1,3 @@
1
+ export const getAppImagePath = () => {
2
+ return process.env.APPIMAGE
3
+ }
@@ -0,0 +1,11 @@
1
+ import { spawn } from 'node:child_process'
2
+
3
+ export const restart = (downloadPath) => {
4
+ const { ELECTRON_RUN_AS_NODE, ...env } = process.env
5
+ // TODO handle errors
6
+ const childProcess = spawn(downloadPath, {
7
+ stdio: 'inherit',
8
+ env,
9
+ })
10
+ childProcess.unref()
11
+ }