Skip to content

Commit

Permalink
Use path.join to resolve issues on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcroda committed Mar 15, 2014
1 parent 6ec3ac7 commit e3a0ee3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var fs = require('fs')
var fs = require('fs'),
p = require('path');

// how to know when you are done?
function readdir(path, callback) {
Expand All @@ -16,13 +17,13 @@ function readdir(path, callback) {
}

files.forEach(function (file) {
fs.stat(path + '/' + file, function (err, stats) {
fs.stat(p.join(path, file), function (err, stats) {
if (err) {
return callback(err)
}

if (stats.isDirectory()) {
files = readdir(path + '/' + file, function (err, res) {
files = readdir(p.join(path, file), function (err, res) {
list = list.concat(res)
pending -= 1
if (!pending) {
Expand All @@ -31,7 +32,7 @@ function readdir(path, callback) {
})
}
else {
list.push(path + '/' + file)
list.push(p.join(path, file))
pending -= 1
if (!pending) {
callback(null, list)
Expand All @@ -42,4 +43,4 @@ function readdir(path, callback) {
})
}

module.exports = readdir
module.exports = readdir

0 comments on commit e3a0ee3

Please sign in to comment.