@lvce-editor/shared-process 0.14.8 → 0.14.9

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.8",
3
+ "version": "0.14.9",
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.8",
21
- "@lvce-editor/extension-host-helper-process": "0.14.8",
22
- "@lvce-editor/pty-host": "0.14.8",
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",
23
23
  "debug": "^4.3.4",
24
24
  "execa": "^7.1.1",
25
25
  "exit-hook": "^3.2.0",
@@ -1,11 +1,12 @@
1
1
  import { spawn } from 'node:child_process'
2
- import { chmod, rename } from 'node:fs/promises'
2
+ import { rename } from 'node:fs/promises'
3
3
  import { tmpdir } from 'node:os'
4
4
  import { 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'
8
8
  import * as GetLatestReleaseVersion from '../GetLatestReleaseVersion/GetLatestReleaseVersion.js'
9
+ import * as MakeExecutable from '../MakeExecutable/MakeExecutable.js'
9
10
  import * as Platform from '../Platform/Platform.js'
10
11
  import { VError } from '../VError/VError.js'
11
12
 
@@ -28,6 +29,7 @@ export const downloadUpdate = async (version) => {
28
29
  const downLoadUrl = getDownloadUrl(repository, version, appImageName)
29
30
  const outFile = getOutfilePath(version)
30
31
  await Download.download(downLoadUrl, outFile)
32
+ return outFile
31
33
  } catch (error) {
32
34
  // @ts-ignore
33
35
  throw new VError(error, `Failed to download new version ${version}`)
@@ -65,17 +67,14 @@ const restart = (downloadPath) => {
65
67
  spawn(downloadPath, { stdio: 'inherit' })
66
68
  }
67
69
 
68
- const makeExecutable = async (file) => {
69
- await chmod(file, 0o755)
70
- }
71
-
72
70
  export const installAndRestart = async (downloadPath) => {
73
71
  try {
72
+ Assert.string(downloadPath)
74
73
  const appImageFile = getAppImagePath()
75
74
  if (!appImageFile) {
76
75
  throw new Error(`AppImage path not found`)
77
76
  }
78
- await makeExecutable(downloadPath)
77
+ await MakeExecutable.makeExecutable(downloadPath)
79
78
  await installNewAppImage(appImageFile, downloadPath)
80
79
  await restart(downloadPath)
81
80
  } catch (error) {
@@ -0,0 +1,10 @@
1
+ import { chmod } from 'node:fs/promises'
2
+ import { VError } from '../VError/VError.js'
3
+
4
+ export const makeExecutable = async (file) => {
5
+ try {
6
+ await chmod(file, 0o755)
7
+ } catch (error) {
8
+ throw new VError(error, `Failed to make file executable`)
9
+ }
10
+ }