Fixes qode path for windows (now it can load dll's easily)

This commit is contained in:
Atul R 2020-02-26 23:39:09 +01:00
parent c74fa1c7f0
commit 43f951b253
3 changed files with 42 additions and 0 deletions

5
package-lock.json generated
View File

@ -7022,6 +7022,11 @@
"tmpl": "1.0.x"
}
},
"manage-path": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/manage-path/-/manage-path-2.0.0.tgz",
"integrity": "sha1-9M+EV7km7u4qg7FzUBQUvHbrlZc="
},
"map-cache": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz",

View File

@ -7,6 +7,9 @@
"author": "Atul R <atulanand94@gmail.com>",
"license": "MIT",
"private": false,
"bin": {
"qode": "./scripts/qode.js"
},
"scripts": {
"dev": "cross-env npm run build && qode dist/demo.js",
"build": "cross-env tsc && npm run build:addon",
@ -25,6 +28,7 @@
"cmake-js": "^6.0.0",
"cross-env": "^7.0.0",
"cuid": "^2.1.6",
"manage-path": "^2.0.0",
"node-addon-api": "^2.0.0",
"postcss-nodegui-autoprefixer": "0.0.7",
"prebuild-install": "^5.3.3"

33
scripts/qode.js Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env node
var path = require('path');
var qodeConfig = require('@nodegui/qode');
var managePath = require('manage-path');
var qtConfig = require('../config/qtConfig');
var proc = require('child_process');
// Add Qt's bin to the path of Qode so that it can find the dll's
var alterPath = managePath(process.env);
alterPath.unshift(path.join(qtConfig.qtHome, 'bin'));
var child = proc.spawn(qodeConfig.qodePath, process.argv.slice(2), {
stdio: 'inherit',
windowsHide: false,
env: process.env,
});
child.on('close', function(code) {
process.exit(code);
});
const handleTerminationSignal = function(signal) {
process.on(signal, function signalHandler() {
if (!child.killed) {
child.kill(signal);
}
});
};
handleTerminationSignal('SIGINT');
handleTerminationSignal('SIGTERM');