From dcd0ce8111613025aa3ae9152a62e7c6cff5d1c6 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Thu, 25 Nov 2021 18:32:43 +0100 Subject: [PATCH] Added lib string-argv to extract bin and args from cmd --- package-lock.json | 16 +++++++++++++++- package.json | 3 ++- src/helper/exec.js | 2 ++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 37faa91..e80026a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,8 @@ "dependencies": { "@influxdata/influxdb-client": "^1.20.0", "log4js": "^6.3.0", - "luxon": "^2.1.1" + "luxon": "^2.1.1", + "string-argv": "^0.3.1" } }, "node_modules/@influxdata/influxdb-client": { @@ -128,6 +129,14 @@ "node": ">=4.0" } }, + "node_modules/string-argv": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", + "integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==", + "engines": { + "node": ">=0.6.19" + } + }, "node_modules/universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -228,6 +237,11 @@ } } }, + "string-argv": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", + "integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==" + }, "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", diff --git a/package.json b/package.json index b7b1bd4..233ef01 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "dependencies": { "@influxdata/influxdb-client": "^1.20.0", "log4js": "^6.3.0", - "luxon": "^2.1.1" + "luxon": "^2.1.1", + "string-argv": "^0.3.1" } } diff --git a/src/helper/exec.js b/src/helper/exec.js index 5523f5c..ed7f628 100644 --- a/src/helper/exec.js +++ b/src/helper/exec.js @@ -1,9 +1,11 @@ const logger = require("./logger.js")("exec"); const { spawn } = require("child_process"); +const { parseArgsStringToArgv } = require('string-argv'); function exec(cmd, options){ + const [bin, ...args] = parseArgsStringToArgv(cmd); logger.addContext("binary", "bin"); logger.debug(`Spawn process '${cmd}'`);