Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

caroot

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

caroot - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

9

index.js

@@ -5,8 +5,9 @@ var path = require('path'),

function caroot(caretedPath, currentPath) {
function caroot(caretedPath, currentPath, rootSubDirectory) {
if(caretedPath.charAt(0) === '^') {
var filePath = caretedPath.slice(1),
root = findRoot(currentPath),
x = path.relative(path.dirname(currentPath), root),
result = path.join(x, filePath);
rootBase = findRoot(currentPath),
root = rootSubDirectory ? path.join(rootBase, rootSubDirectory) : rootBase,
relativePath = path.relative(path.dirname(currentPath), root),
result = path.join(relativePath, filePath);

@@ -13,0 +14,0 @@ if(result.match(relativeRegex)){

{
"name": "caroot",
"version": "1.0.0",
"version": "1.1.0",
"description": "Replaces a caret with the root path",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -7,2 +7,4 @@ # caroot

caroot(caretedPath, currentPath[, rootSubDirectory])
```javascript

@@ -18,2 +20,9 @@

// also takes an optional root sub directory
caroot('^foo', __dirname, './scripts');
// returns '../foo'
```

@@ -5,6 +5,5 @@ var test = require('tape'),

function resolve(caretedPath, currentPath){
function resolve(caretedPath, currentPath, subDirectory){
var directory = path.resolve(__dirname, currentPath);
return caroot(caretedPath, directory);
return caroot(caretedPath, directory, subDirectory);
}

@@ -112,1 +111,11 @@

});
test('root sub directory', function(t) {
t.plan(1);
t.equal(
resolve('^things/stuff', './foo/bar/things/stuff/majigger', './tests/foo/bar/'),
'../../things/stuff',
'Resolves correctly'
);
});
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