Closed ArendJan closed 1 year ago
Also change
__dirname+"/hostscript.js",
to
p.join(__dirname, 'hostscript.js'),
and add
const p = require('path');
path.join
is not necessary because Windows supports the use of "/"
it is because the hazardous package modifies the path.join function, and with just __dirname it will return the filename within the locked app.asar file, whereas with join, it will return the location of the unpacked file:
Normal:
C:\Program Files\Ladderino\resources\app.asar\node_modules\winattr\lib\shell/hostscript.js
path.join version:
C:\Program Files\Ladderino\resources\app.asar.unpacked\node_modules\winattr\lib\shell\hostscript.js
Its have Warnings with electron build: This is with @akryum/winattr but its the same with winattr too:
[1] [2] WARNING in ./node_modules/fswin/node/5.x.x/ia32/fswin.node 1:2
[1] [2] Module parse failed: Unexpected character '�' (1:2)
[1] [2] You may need an appropriate loader to handle this file type.
[1] [2] (Source code omitted for this binary file)
[1] [2] @ ./node_modules/fswin sync ^.*\/fswin\.node$ ./node/5.x.x/ia32/fswin.node
[1] [2] @ ./node_modules/fswin/index.js
[1] [2] @ ./node_modules/@akryum/winattr/lib/binding/index.js
[1] [2] @ ./node_modules/@akryum/winattr/lib/whichLib.js
[1] [2] @ ./node_modules/@akryum/winattr/lib/index.js
[1] [2] @ ./app/services/electron-io.js
[1] [2] @ ./app/services/platform-io.js
[1] [2] @ ./app/services/thumbsgenerator.js
[1] [2] @ ./app/splash-worker.js
[1] [2] @ multi ./app/splash-worker.js
When building using electron-builder, the hostscript.js file will be put in a .asar file, which is not readably by cscript.exe, which will lead to an exception in a json.parse call.
To fix this, you can install hazardous and add
require('hazardous');
to the top ofwinattr/lib/shell/index.js
(before requiring the path).Then add
"asar": true, "asarUnpack": ["node_modules/winattr/lib/shell/hostscript.js"],
to you package.json and it is fixed.