Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gabrielcsapo/node-git-server
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielcsapo committed Nov 27, 2018
2 parents dd20baf + f19a1c1 commit 4c974e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const through = require('through');
const zlib = require('zlib');
const util = require('util');
const os = require('os');
const { spawn } = require('child_process');

const HttpDuplex = require('./http-duplex');
Expand Down Expand Up @@ -103,7 +104,11 @@ class Service extends HttpDuplex {

self.once('accept', function onAccept() {
process.nextTick(function() {
const cmd = ['git-' + opts.service, '--stateless-rpc', opts.cwd];
const cmd = os.platform() == 'win32' ?
['git', opts.service, '--stateless-rpc', opts.cwd]
:
['git-' + opts.service, '--stateless-rpc', opts.cwd];

const ps = spawn(cmd[0], cmd.slice(1));

ps.on('error', function(err) {
Expand Down
9 changes: 8 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@ const Util = {
res.write(pack('# service=git-' + service + '\n'));
res.write('0000');

const cmd = ['git-' + service, '--stateless-rpc', '--advertise-refs', repoLocation];
var cmd = null;
var isWin = /^win/.test(process.platform);
if (isWin) {
cmd = ['git', service, '--stateless-rpc', '--advertise-refs', repoLocation];
} else {
cmd = ['git-' + service, '--stateless-rpc', '--advertise-refs', repoLocation];
}

const ps = spawn(cmd[0], cmd.slice(1));
ps.on('error', (err) => {
dup.emit('error', new Error(`${err.message} running command ${cmd.join(' ')}`));
Expand Down

0 comments on commit 4c974e3

Please sign in to comment.