Skip to content

Commit 5711c7a

Browse files
echopointgabrielcsapo
authored andcommitted
fixes pathing issues on non linux/unix based oses (windows) (#22)
* fixes pathing issues on non linux/unix based oses (windows) * converted tabs to spaces
1 parent f114632 commit 5711c7a

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

example/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Server = require('../');
44

55
const port = process.env.PORT || 7005;
66

7-
const git = new Server(path.resolve(__dirname, 'tmp'), {
7+
const git = new Server(path.normalize(path.resolve(__dirname, 'tmp')), {
88
autoCreate: true,
99
authenticate: (type, repo, username, password, next) => {
1010
console.log(type, repo, username, password); // eslint-disable-line

lib/git.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,7 @@ class Git extends EventEmitter {
145145
this.dirMap = repoDir;
146146
} else {
147147
this.dirMap = (dir) => {
148-
if(dir) {
149-
return path.resolve(repoDir, dir);
150-
} else {
151-
return repoDir;
152-
}
148+
return (path.normalize(dir ? path.resolve(repoDir, dir) : repoDir));
153149
};
154150
}
155151

@@ -189,9 +185,9 @@ class Git extends EventEmitter {
189185
*/
190186
mkdir(dir, callback) {
191187
// TODO: remove sync operations
192-
const parts = this.dirMap(dir).split('/');
188+
const parts = this.dirMap(dir).split(path.sep);
193189
for(var i = 0; i <= parts.length; i++) {
194-
const directory = parts.slice(0, i).join('/');
190+
const directory = parts.slice(0, i).join(path.sep);
195191
if(directory && !fs.existsSync(directory)) {
196192
fs.mkdirSync(directory);
197193
}

0 commit comments

Comments
 (0)