Skip to content

Commit 5b233a2

Browse files
atsamd21woodser
authored andcommitted
Fix process start/kill on windows
1 parent 3023b55 commit 5b233a2

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
],
1111
"scripts": {
1212
"prepare": "scripts/build_protobuf.sh",
13-
"test": "node ./node_modules/.bin/jest --forceExit --detectOpenHandles",
13+
"test": "jest --forceExit --detectOpenHandles",
1414
"eslint": "eslint .",
1515
"eslintfix": "eslint src/* --fix",
1616
"typedoc": "typedoc ./src/index.ts --entryPointStrategy expand src/ --exclude **/*.test.ts --excludePrivate"

src/HavenoClient.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3963,7 +3963,7 @@ async function initHaveno(ctx?: HavenodContext): Promise<HavenoClient> {
39633963

39643964
// start haveno process using configured ports if available
39653965
const cmd: string[] = [
3966-
"./haveno-daemon",
3966+
(process.platform === 'win32'? "haveno-daemon.bat" : "./haveno-daemon"),
39673967
"--baseCurrencyNetwork", TestConfig.baseCurrencyNetwork,
39683968
"--useLocalhostForP2P", TestConfig.baseCurrencyNetwork === BaseCurrencyNetwork.XMR_MAINNET ? "false" : "true", // TODO: disable for stagenet too
39693969
"--useDevPrivilegeKeys", TestConfig.baseCurrencyNetwork === BaseCurrencyNetwork.XMR_LOCAL ? "true" : "false",

src/HavenoClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default class HavenoClient {
145145
let daemon: HavenoClient | undefined = undefined;
146146

147147
// start process
148-
const childProcess = require('child_process').spawn(cmd[0], cmd.slice(1), {cwd: havenoPath});
148+
const childProcess = require('child_process').spawn(cmd[0], cmd.slice(1), {cwd: havenoPath, shell: process.platform === 'win32'});
149149
childProcess.stdout.setEncoding('utf8');
150150
childProcess.stderr.setEncoding('utf8');
151151

src/utils/HavenoUtils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import assert from "assert";
1919
import console from "console";
2020
import Decimal from 'decimal.js';
2121
import { PaymentAccountForm, PaymentAccountFormField } from "../protobuf/pb_pb";
22+
import { exec } from "child_process";
2223

2324
/**
2425
* Collection of utilities for working with Haveno.
@@ -88,7 +89,14 @@ export default class HavenoUtils {
8889
return new Promise(function(resolve, reject) {
8990
process.on("exit", function() { resolve(); });
9091
process.on("error", function(err: any) { reject(err); });
91-
process.kill(signal ? signal : "SIGINT");
92+
93+
if (global.process.platform === 'win32') {
94+
exec(`taskkill /PID ${process.pid} /T /F`, err => {
95+
if (err) reject(err);
96+
});
97+
} else {
98+
process.kill(signal ? signal : "SIGINT");
99+
}
92100
});
93101
}
94102

0 commit comments

Comments
 (0)