Permalink
Browse files

Merge pull request #4 from aksh3ll/patch-1

Update for compatibility with Windows' version of node.js
  • Loading branch information...
2 parents fcf0187 + 4bdfc66 commit ee84a58636e561f5ef0b37738fd206c29952d3ef Bruno Pedro committed Mar 2, 2012
Showing with 6 additions and 5 deletions.
  1. +6 −5 lib/fs.js
View
@@ -3,7 +3,8 @@
var fs = require('fs'),
mkdirOrig = fs.mkdir,
- mkdirSyncOrig = fs.mkdirSync;
+ mkdirSyncOrig = fs.mkdirSync,
+ osSep = process.platform === 'win32' ? '\\' : '/';
/**
* Offers functionality similar to mkdir -p
@@ -12,7 +13,7 @@
* are given to the completion callback.
*/
function mkdir_p (path, mode, callback, position) {
- var parts = require('path').normalize(path).split('/');
+ var parts = require('path').normalize(path).split(osSep);
mode = mode || process.umask();
position = position || 0;
@@ -21,7 +22,7 @@
return callback();
}
- var directory = parts.slice(0, position + 1).join('/') || '/';
+ var directory = parts.slice(0, position + 1).join(osSep) || osSep;
fs.stat(directory, function(err) {
if (err === null) {
mkdir_p(path, mode, callback, position + 1);
@@ -38,7 +39,7 @@
}
function mkdirSync_p(path, mode, position) {
- var parts = require('path').normalize(path).split('/');
+ var parts = require('path').normalize(path).split(osSep);
mode = mode || process.umask();
position = position || 0;
@@ -47,7 +48,7 @@
return true;
}
- var directory = parts.slice(0, position + 1).join('/') || '/';
+ var directory = parts.slice(0, position + 1).join(osSep) || osSep;
try {
fs.statSync(directory);
mkdirSync_p(path, mode, position + 1);

0 comments on commit ee84a58

Please sign in to comment.