diff --git a/lib/helpers/run-git-command.js b/lib/helpers/run-git-command.js index 4049687..937521f 100644 --- a/lib/helpers/run-git-command.js +++ b/lib/helpers/run-git-command.js @@ -1,5 +1,5 @@ -var exec = require('child_process').execFile -var execFileSync = require('child_process').execFileSync +var { execFile } = require('child_process') +var { execFileSync } = require('child_process') var path = require('path') var removeEmptyLines = require('./remove-empty-lines') @@ -10,19 +10,21 @@ module.exports = function (gitWorkTree, command, callback) { '--git-dir=' + path.join(gitWorkTree, '.git'), '--work-tree=' + gitWorkTree, command - ].join(' ').split(' ') + ].join(' ') : [ 'git', command - ].join(' ').split(' ') + ].join(' ') + gitCommand = gitCommand.match(/('(\\'|[^'])*'|"(\\"|[^"])*"|\/(\\\/|[^\/])*\/|(\\ |[^ ])+|[\w-]+)/g) + if (callback) { - console.log(gitCommand[0]) - exec(gitCommand[0], gitCommand.slice(1), function (err, stdout) { + execFile(gitCommand[0], gitCommand.slice(1), function (err, stdout) { if (err) { return callback(err) } callback(null, removeEmptyLines(stdout)) }) } else { + console.log(gitCommand) return removeEmptyLines('' + execFileSync(gitCommand[0], gitCommand.slice(1))) } }