New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

parents

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parents - npm Package Compare versions

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(/:\.$/, ':')
}
}
}

6

package.json
{
"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 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc