Added lib string-argv to extract bin and args from cmd

f_influx-checks
Ruakij 3 years ago
parent 1a9ced0bb8
commit dcd0ce8111

16
package-lock.json generated

@ -11,7 +11,8 @@
"dependencies": { "dependencies": {
"@influxdata/influxdb-client": "^1.20.0", "@influxdata/influxdb-client": "^1.20.0",
"log4js": "^6.3.0", "log4js": "^6.3.0",
"luxon": "^2.1.1" "luxon": "^2.1.1",
"string-argv": "^0.3.1"
} }
}, },
"node_modules/@influxdata/influxdb-client": { "node_modules/@influxdata/influxdb-client": {
@ -128,6 +129,14 @@
"node": ">=4.0" "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": { "node_modules/universalify": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", "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": { "universalify": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",

@ -16,6 +16,7 @@
"dependencies": { "dependencies": {
"@influxdata/influxdb-client": "^1.20.0", "@influxdata/influxdb-client": "^1.20.0",
"log4js": "^6.3.0", "log4js": "^6.3.0",
"luxon": "^2.1.1" "luxon": "^2.1.1",
"string-argv": "^0.3.1"
} }
} }

@ -1,9 +1,11 @@
const logger = require("./logger.js")("exec"); const logger = require("./logger.js")("exec");
const { spawn } = require("child_process"); const { spawn } = require("child_process");
const { parseArgsStringToArgv } = require('string-argv');
function exec(cmd, options){ function exec(cmd, options){
const [bin, ...args] = parseArgsStringToArgv(cmd);
logger.addContext("binary", "bin"); logger.addContext("binary", "bin");
logger.debug(`Spawn process '${cmd}'`); logger.debug(`Spawn process '${cmd}'`);

Loading…
Cancel
Save