From 43f951b253daafd0e339c4ab018cae26e4dc131a Mon Sep 17 00:00:00 2001 From: Atul R Date: Wed, 26 Feb 2020 23:39:09 +0100 Subject: [PATCH] Fixes qode path for windows (now it can load dll's easily) --- package-lock.json | 5 +++++ package.json | 4 ++++ scripts/qode.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 scripts/qode.js diff --git a/package-lock.json b/package-lock.json index ae35c1469..9cda846bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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", diff --git a/package.json b/package.json index 98b7db58b..24132ddaf 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,9 @@ "author": "Atul R ", "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" diff --git a/scripts/qode.js b/scripts/qode.js new file mode 100644 index 000000000..689190696 --- /dev/null +++ b/scripts/qode.js @@ -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');