Comparing version 0.0.2 to 0.0.3
22
index.js
@@ -1,2 +0,2 @@ | ||
var path = require('path'); | ||
var pathPlatform = require('path-platform'); | ||
@@ -9,2 +9,6 @@ module.exports = function (cwd, opts) { | ||
var isWindows = /^win/.test(platform); | ||
var path = isWindows ? pathPlatform.win32 : pathPlatform; | ||
var normalize = !isWindows ? path.normalize : | ||
path.normalize('c:') === 'c:.' ? fixNormalize(path.normalize) : | ||
path.normalize; | ||
var sep = isWindows ? /[\\\/]/ : '/'; | ||
@@ -17,6 +21,7 @@ var init = isWindows ? '' : '/'; | ||
}); | ||
return path.normalize(ps.join(isWindows ? '\\' : '/')); | ||
return normalize(ps.join(isWindows ? '\\' : '/')); | ||
}; | ||
var res = path.normalize(cwd) | ||
var res = normalize(cwd) | ||
.split(sep) | ||
@@ -32,6 +37,15 @@ .reduce(function (acc,dir,ix) { | ||
return res.slice(0,-1).map(function (d) { | ||
return d.replace(/^\./, ''); | ||
var ch = d.charAt(0) | ||
return ch === '\\' ? d : | ||
ch === '.' ? '\\' + d.slice(1) : | ||
'\\' + d | ||
}); | ||
} | ||
return res; | ||
function fixNormalize(fn) { | ||
return function(p) { | ||
return fn(p).replace(/:\.$/, ':') | ||
} | ||
} | ||
} |
{ | ||
"name" : "parents", | ||
"version" : "0.0.2", | ||
"version" : "0.0.3", | ||
"description" : "return all the parent directories for a directory", | ||
@@ -11,3 +11,5 @@ "main" : "index.js", | ||
}, | ||
"dependencies" : {}, | ||
"dependencies" : { | ||
"path-platform": "^0.0.1" | ||
}, | ||
"devDependencies" : { | ||
@@ -14,0 +16,0 @@ "tap" : "~0.2.5" |
@@ -5,10 +5,10 @@ var test = require('tap').test; | ||
test('win32', function (t) { | ||
var dir = 'C:\\Program Files\\Maxis\\Sim City 2000\\cities'; | ||
var dir = 'c:\\Program Files\\Maxis\\Sim City 2000\\cities'; | ||
var dirs = parents(dir, { platform : 'win32' }); | ||
t.same(dirs, [ | ||
'C:\\Program Files\\Maxis\\Sim City 2000\\cities', | ||
'C:\\Program Files\\Maxis\\Sim City 2000', | ||
'C:\\Program Files\\Maxis', | ||
'C:\\Program Files', | ||
'C:', | ||
'c:\\Program Files\\Maxis\\Sim City 2000\\cities', | ||
'c:\\Program Files\\Maxis\\Sim City 2000', | ||
'c:\\Program Files\\Maxis', | ||
'c:\\Program Files', | ||
'c:', | ||
]); | ||
@@ -19,4 +19,4 @@ t.end(); | ||
test('win32 c:', function (t) { | ||
var dirs = parents('C:\\', { platform : 'win32' }); | ||
t.same(dirs, [ 'C:' ]); | ||
var dirs = parents('c:\\', { platform : 'win32' }); | ||
t.same(dirs, [ 'c:' ]); | ||
t.end(); | ||
@@ -23,0 +23,0 @@ }); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6519
98
0
1
+ Addedpath-platform@^0.0.1
+ Addedpath-platform@0.0.1(transitive)