Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize relativePath #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
var fs = require('fs');
var path = require('path');
var relativePath = require('cached-path-relative')

var browserResolve = require('browser-resolve');
var nodeResolve = require('resolve');
var detective = require('detective');
Expand All @@ -12,6 +10,7 @@ var combine = require('stream-combiner2');
var duplexer = require('duplexer2');
var xtend = require('xtend');
var defined = require('defined');
var relativePathCache = {};

var inherits = require('inherits');
var Transform = require('readable-stream').Transform;
Expand Down Expand Up @@ -562,3 +561,9 @@ function wrapTransform (tr) {
tr.on('error', function (err) { wrapper.emit('error', err) });
return wrapper;
}

function relativePath (from, to) {
var key = from + to;
return relativePathCache[key] ||
(relativePathCache[key] = path.relative(from, to));
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"dependencies": {
"JSONStream": "^1.0.3",
"browser-resolve": "^1.7.0",
"cached-path-relative": "^1.0.0",
"concat-stream": "~1.5.0",
"defined": "^1.0.0",
"detective": "^4.0.0",
Expand Down