Skip to content

Commit

Permalink
fix: don't use process as variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
themightychris committed Dec 9, 2024
1 parent ee79ead commit 0985456
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/Git.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,23 +449,23 @@ class Git {
logger.debug(`${this.command} ${commandArgs.join(' ')}`);

if (execOptions.spawn) {
const process = child_process.spawn(this.command, commandArgs, execOptions);
const gitProcess = child_process.spawn(this.command, commandArgs, execOptions);

if (execOptions.passthrough) {
process.stdout.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => logger.info(line.trimEnd())));
process.stderr.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => logger.error(line.trimEnd())));
gitProcess.stdout.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => logger.info(line.trimEnd())));
gitProcess.stderr.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => logger.error(line.trimEnd())));
} else {
if (execOptions.onStdout) {
process.stdout.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => execOptions.onStdout(line.trimEnd())));
gitProcess.stdout.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => execOptions.onStdout(line.trimEnd())));
}
if (execOptions.onStderr) {
process.stderr.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => execOptions.onStderr(line.trimEnd())));
gitProcess.stderr.on('data', data => data.toString().trimEnd().split(/\n/).forEach(line => execOptions.onStderr(line.trimEnd())));
}
}

if (execOptions.wait) {
return new Promise((resolve, reject) => {
process.on('exit', code => {
gitProcess.on('exit', code => {
if (code == 0) {
resolve();
} else {
Expand All @@ -476,20 +476,20 @@ class Git {
}

let capturePromise;
process.captureOutput = (input = null) => {
gitProcess.captureOutput = (input = null) => {
if (!capturePromise) {
capturePromise = new Promise((resolve, reject) => {
let output = '', error = '';

process.stdout.on('data', data => {
gitProcess.stdout.on('data', data => {
output += data;
});

process.stderr.on('data', data => {
gitProcess.stderr.on('data', data => {
error += data;
});

process.on('close', code => {
gitProcess.on('close', code => {
if (code == 0) {
resolve(output);
} else {
Expand All @@ -504,18 +504,18 @@ class Git {
}

if (input) {
process.stdin.write(input);
process.stdin.end();
gitProcess.stdin.write(input);
gitProcess.stdin.end();
}

return capturePromise;
};

process.captureOutputTrimmed = async (input = null) => {
return (await process.captureOutput(input)).trim();
gitProcess.captureOutputTrimmed = async (input = null) => {
return (await gitProcess.captureOutput(input)).trim();
};

return process;
return gitProcess;
} else if (execOptions.shell) {
return new Promise((resolve, reject) => {
child_process.exec(`${this.command} ${commandArgs.join(' ')}`, execOptions, (error, stdout, stderr) => {
Expand Down

0 comments on commit 0985456

Please sign in to comment.