Socket
Socket
Sign inDemoInstall

next

Package Overview
Dependencies
Maintainers
1
Versions
2773
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next - npm Package Compare versions

Comparing version 0.2.12 to 0.2.13

12

lib/find-package-root.js

@@ -7,8 +7,9 @@ // For given path returns root package path.

var stat = require('fs').stat
, dirname = require('path').dirname
, path = require('path')
, basename = path.basename
, dirname = path.dirname
, resolve = path.resolve
, contains = require('es5-ext/lib/Array/prototype/contains')
, dirExists = require('./fs/dir-exists')
, fileExists = require('./fs/file-exists')
, normalize = require('./path/normalize')
, separator = require('./path/separator')

@@ -39,4 +40,3 @@ , isPackageRoot, cache = [];

callback(null, null);
} else if (parentpath.slice(parentpath.lastIndexOf(separator) + 1)
=== 'node_modules') {
} else if (basename(parentpath) === 'node_modules') {
cache.push(path);

@@ -53,3 +53,3 @@ callback(null, path);

module.exports = function find(path, callback) {
path = normalize(path);
path = resolve(String(path));
stat(path, function (err, stats) {

@@ -56,0 +56,0 @@ if (err) {

@@ -5,8 +5,8 @@ // Get all files at path

var stat = require('fs').lstat
, normalize = require('../path/normalize')
, readdir = require('./readdir-files-deep');
var stat = require('fs').lstat
, resolve = require('path').resolve
, readdir = require('./readdir-files-deep');
module.exports = function (path, cb) {
path = normalize(path);
path = resolve(String(path));
stat(path, function (err, stats) {

@@ -26,3 +26,3 @@ if (err) {

cb(null, files.map(function (file) {
return normalize(path + '/' + file);
return resolve(path, file);
}));

@@ -29,0 +29,0 @@ });

@@ -6,5 +6,5 @@ // Read all filenames from directory and it's subdirectories

var fs = require('fs')
, resolve = require('path').resolve
, k = require('es5-ext/lib/Function/k')
, promisify = require('deferred').promisify
, normalize = require('../path/normalize')

@@ -14,4 +14,4 @@ , readdir = promisify(fs.readdir), stat = promisify(fs.lstat);

module.exports = function (path, callback) {
readdir(path = normalize(path)).map(function (file) {
var npath = path + '/' + file;
readdir(path = resolve(String(path))).map(function (file) {
var npath = resolve(path, file);
return stat(npath)(function (stats) {

@@ -18,0 +18,0 @@ return stats.isDirectory() ? file : null;

@@ -10,3 +10,3 @@ // Read all filenames from directory and it's subdirectories

, fs = require('fs')
, normalize = require('../path/normalize')
, path = require('path')
, compact = require('es5-ext/lib/Array/prototype/compact')

@@ -22,2 +22,3 @@ , contains = require('es5-ext/lib/Array/prototype/contains')

, readdir = fs.readdir, lstat = fs.lstat, readFile = fs.readFile
, join = path.join, resolve = path.resolve
, read, read2, match, match2, prepIgnore;

@@ -139,3 +140,3 @@

result = result.concat(res.map(function (name) {
return normalize(file + '/' + name);
return join(file, name);
}));

@@ -181,3 +182,3 @@ if (!--waiting) {

ignore = { "/": ignore };
readdir(path = normalize(path), function (err, files) {
readdir(path = resolve(String(path)), function (err, files) {
if (err) {

@@ -184,0 +185,0 @@ cb(err);

@@ -6,5 +6,5 @@ // Read all filenames from directory and it's subdirectories

var fs = require('fs')
, resolve = require('path').resolve
, k = require('es5-ext/lib/Function/k')
, promisify = require('deferred').promisify
, normalize = require('../path/normalize')

@@ -14,4 +14,4 @@ , readdir = promisify(fs.readdir), stat = promisify(fs.lstat);

module.exports = function self(path, callback) {
readdir(path = normalize(path)).map(function (file) {
var npath = path + '/' + file;
readdir(path = resolve(String(path))).map(function (file) {
var npath = resolve(path, file);
return stat(npath)(function (stats) {

@@ -18,0 +18,0 @@ return stats.isFile() ? file : null;

@@ -10,6 +10,5 @@ // Return require function for given path

, path = require('path')
, ptrim = require('./path/trim')
, stat = fs.statSync
, getDirname = path.dirname, nodeCache = Module._cache
, getDirname = path.dirname, resolve = path.resolve, nodeCache = Module._cache

@@ -29,3 +28,3 @@ , cache = {}, getFromNodeCache;

'environment variable instead.');
}});
} });
} else {

@@ -55,3 +54,3 @@ // <= v0.4

var dirname, stats, path, id, fmodule;
filename = ptrim(filename);
filename = resolve(filename);
if (cache[filename]) {

@@ -58,0 +57,0 @@ return cache[filename];

@@ -5,8 +5,6 @@ // End path with slash

var normalize = require('./normalize')
, separator = require('./separator');
var join = require('path').join;
module.exports = function (path) {
path = normalize(path);
return (path && (path !== separator)) ? (path + separator) : path;
return join(path, 'x').slice(0, -1);
};

@@ -5,63 +5,34 @@ // Finds relative path between two absolute paths

var normalize = require('path').normalize
, contains = require('es5-ext/lib/String/prototype/contains')
, sysSep = require('./separator')
, normalize2 = require('./normalize')
var path = require('path')
, commonLeft = require('es5-ext/lib/Array/prototype/common-left')
, peek = require('es5-ext/lib/Array/prototype/peek')
, separator = require('./separator')
, re = /^[A-Z]\:[\\\/]/;
, join = path.join, resolve = path.resolve;
module.exports = function (from, to) {
var x, y, separator, sfrom, orgto
, prefrom = from;
orgto = to;
if (contains.call(from, '/') && contains.call(from, '\\')) {
from = normalize2(from);
separator = sysSep;
var index, str, added;
if (arguments.length < 2) {
to = from;
from = process.cwd();
}
if (to && contains.call(to, '/') && contains.call(to, '\\')) {
to = normalize2(to);
separator = sysSep;
from = String(from);
if (join(peek.call(from)) === separator) {
from = join(from, 'x');
}
if (!separator) {
if (contains.call(from, '/') || contains.call(to, '/')) {
separator = '/';
sfrom = /\\/g;
} else if (contains.call(from, '\\') || contains.call(to, '\\')) {
separator = '\\';
sfrom = /\//g;
} else {
separator = sysSep;
}
from = normalize(from).replace(sfrom, separator);
to = to && normalize(to).replace(sfrom, separator);
to = String(to);
if (join(peek.call(to)) === separator) {
to = join(to, 'x');
added = true;
}
if (from.match(re)) {
from = from.slice(2);
}
if (to && to.match(re)) {
to = to.slice(2);
}
if (from.charAt(0) !== separator) {
throw new Error("node-ext.path.relative error: "
+ "Paths should be absolute");
}
if (orgto == null) {
to = from;
from = process.cwd() + separator;
if (from.match(re)) {
from = from.slice(2);
}
} else if (to.charAt(0) !== separator) {
throw new Error("node-ext.path.relative error: "
+ "Paths should be absolute");
}
from = resolve(from);
to = resolve(to);
x = from.split(separator);
y = to.split(separator);
while (x.length && (x[0] === y[0])) {
x.shift();
y.shift();
}
return new Array(x.length).join(".." + separator) + y.join(separator);
index = commonLeft.call(from, to);
from = from.slice(index);
to = to.slice(index);
return (new Array(from.split(separator).length).join('..' + separator) +
(added ? to.slice(0, -1) : to));
};
// Require first named module in tree (traversing up)
'use strict';

@@ -7,13 +8,12 @@

, errorMsg = require('./is-module-not-found-error')
, normalize = require('./path/normalize')
, separator = require('./path/separator')
, dirname = path.dirname;
, dirname = path.dirname, join = path.join;
module.exports = function (name, path, root) {
var m;
path = normalize(path);
root = root ? normalize(root) : separator;
path = join(path);
root = root ? join(root) : separator;
while (true) {
m = requireSilent(path + '/' + name);
m = requireSilent(path + separator + name);
if (m) {

@@ -20,0 +20,0 @@ if (m instanceof Error) {

{
"name": "next",
"version": "0.2.12",
"version": "0.2.13",
"description": "Node.js extensions",

@@ -5,0 +5,0 @@ "keywords": ["node", "nodejs", "node.js", "extensions", "addons", "extras"],

'use strict';
var path = require('path')
, normalize = path.normalize
, dirname = path.dirname, join = path.join
, pgPath;
pgPath = path.dirname(__dirname) + '/__playground/dirscan';
pgPath = join(dirname(__dirname), '__playground/dirscan');

@@ -29,3 +30,3 @@ module.exports = function (t) {

'two/one'].map(normalize).sort());
'two/one'].map(join).sort());
d();

@@ -48,3 +49,3 @@ });

'one/one/nine',
'one/one/nine.else', 'one/one/nine.keep'].map(normalize).sort());
'one/one/nine.else', 'one/one/nine.keep'].map(join).sort());
d();

@@ -70,3 +71,3 @@ });

'two/one'].map(normalize).sort());
'two/one'].map(join).sort());
d();

@@ -90,3 +91,3 @@ });

'two/one'].map(normalize).sort());
'two/one'].map(join).sort());
d();

@@ -110,3 +111,3 @@ });

'two/one'].map(normalize).sort());
'two/one'].map(join).sort());
d();

@@ -128,3 +129,3 @@ });

'one/one/nine', 'one/one/nine.keep'].map(normalize).sort());
'one/one/nine', 'one/one/nine.keep'].map(join).sort());
d();

@@ -146,3 +147,3 @@ });

'one/one/nine', 'one/one/nine.keep'].map(normalize).sort());
'one/one/nine', 'one/one/nine.keep'].map(join).sort());
d();

@@ -149,0 +150,0 @@ });

'use strict';
var pg = __dirname + '/__playground';
var join = require('path').join
, pg = join(__dirname, '__playground');

@@ -14,4 +15,4 @@ module.exports = {

"Resolve": function (t, a) {
a(t(pg).resolve('./sample'), pg + '/sample.js');
a(t(pg).resolve('./sample'), join(pg, 'sample.js'));
}
};
'use strict';
var normalize = require('../../lib/path/normalize')
var join = require('path').join
, separator = require('../../lib/path/separator');
module.exports = function (t, a) {
a(t('raz/dwa/'), normalize('raz/dwa') + separator, "With ending slash");
a(t('/raz/dwa'), normalize('/raz/dwa') + separator, "Without ending slash");
a(t('raz/dwa/'), join('raz/dwa') + separator, "With ending slash");
a(t('/raz/dwa'), join('/raz/dwa') + separator, "Without ending slash");
a(t(''), '', "Empty");
a(t('/'), separator, "Root");
};
'use strict';
var join = require('path').join;
module.exports = {

@@ -8,29 +10,20 @@ "Same paths": function (t, a) {

"From deeper than to": function (t, a) {
a.equal(t('/a/b/c/d/', '/a/b/'), '../../');
a.equal(t('/a/b/c/d/', '/a/b/'), join('../../'));
},
"From deeper than to (file)": function (t, a) {
a.equal(t('/a/b/c/d/', '/a/b/x'), '../../x');
a.equal(t('/a/b/c/d/', '/a/b/x'), join('../../x'));
},
"To deeper than from": function (t, a) {
a.equal(t('/a/b/', '/a/b/c/d/'), 'c/d/');
a.equal(t('/a/b/', '/a/b/c/d/'), join('c/d/'));
},
"To deeper than from (file)": function (t, a) {
a.equal(t('/a/b/', '/a/b/c/d/x'), 'c/d/x');
a.equal(t('/a/b/', '/a/b/c/d/x'), join('c/d/x'));
},
"Different paths": function (t, a) {
a.equal(t('/a/b/c/', '/e/f/g/'), '../../../e/f/g/');
a.equal(t('/a/b/c/', '/e/f/g/'), join('../../../e/f/g/'));
},
"CWD": function (t, a) {
a.equal(t(__dirname + '/a/b/'), t(process.cwd(), __dirname + '/a/b/'));
},
"Error on relative from": function (t, a) {
a.throws(function () {
t('raz/dwa', '/fad/ra/');
});
},
"Error on relative to": function (t, a) {
a.throws(function () {
t('/raz/dwa', 'fad/ra/');
});
a.equal(t(__dirname + '/a/b/'), t(process.cwd(),
__dirname + join('/a/b/')));
}
};

Sorry, the diff of this file is not supported yet

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