pinokiod 8.3.20 → 8.3.21

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.
@@ -18,10 +18,16 @@ const KEY = "windows_console"
18
18
  const DEFAULT = "default"
19
19
  const BUNDLED = "bundled"
20
20
 
21
- // Where the pty library's install step puts its copy: next to its native module.
21
+ // Inside the desktop app the library resolves to a path in the app archive
22
+ // (app.asar), while its native module and these files are real files in the
23
+ // folder beside it (app.asar.unpacked). Files put there when the app is built
24
+ // are not listed in the archive, so they are only found by the real path.
25
+ const outsideArchive = (dir, sep = path.sep) => dir.split(`app.asar${sep}`).join(`app.asar.unpacked${sep}`)
26
+
27
+ // Where the copy has to be for the library to load it: next to its native module.
22
28
  const bundledFiles = () => {
23
29
  const root = path.dirname(require.resolve('@homebridge/node-pty-prebuilt-multiarch/package.json'))
24
- const dir = path.join(root, 'build', 'Release', 'conpty')
30
+ const dir = path.join(outsideArchive(root), 'build', 'Release', 'conpty')
25
31
  return ['conpty.dll', 'OpenConsole.exe'].map((file) => path.join(dir, file))
26
32
  }
27
33
 
@@ -65,4 +71,4 @@ const ptyOptions = (kernel, available = bundledAvailable) => {
65
71
  return available() ? { useConptyDll: true } : {}
66
72
  }
67
73
 
68
- module.exports = { KEY, settings, save, ptyOptions, bundledAvailable, bundledFiles }
74
+ module.exports = { KEY, settings, save, ptyOptions, bundledAvailable, bundledFiles, outsideArchive }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "8.3.20",
3
+ "version": "8.3.21",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -82,6 +82,19 @@ test('the bundled layer counts as there only when both of its files are', (t) =>
82
82
  assert.deepEqual(expected, ['build/Release/conpty/conpty.dll', 'build/Release/conpty/OpenConsole.exe'])
83
83
  })
84
84
 
85
+ test('inside the desktop app the files are looked for beside the app archive', () => {
86
+ const win = 'C:\\Pinokio\\resources\\app.asar\\node_modules\\@homebridge\\node-pty-prebuilt-multiarch'
87
+ assert.equal(
88
+ WindowsConsole.outsideArchive(win, '\\'),
89
+ 'C:\\Pinokio\\resources\\app.asar.unpacked\\node_modules\\@homebridge\\node-pty-prebuilt-multiarch'
90
+ )
91
+ // already the real folder, or not in the desktop app at all: unchanged
92
+ const unpacked = 'C:\\Pinokio\\resources\\app.asar.unpacked\\node_modules\\x'
93
+ assert.equal(WindowsConsole.outsideArchive(unpacked, '\\'), unpacked)
94
+ assert.equal(WindowsConsole.outsideArchive('C:\\src\\pinokiod\\node_modules\\x', '\\'), 'C:\\src\\pinokiod\\node_modules\\x')
95
+ assert.equal(WindowsConsole.outsideArchive('/opt/app.asar/node_modules/x', '/'), '/opt/app.asar.unpacked/node_modules/x')
96
+ })
97
+
85
98
  test('the pty library still takes the option this hands it', () => {
86
99
  // The option is passed straight to the library. If an upgrade renames or
87
100
  // drops it, the Settings choice would silently do nothing.