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

calcdeps

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calcdeps - npm Package Compare versions

Comparing version 0.1.2 to 0.1.4

test/goog/base.js

6

bin/calcdeps.js

@@ -69,2 +69,3 @@ #!/usr/bin/env node

console.error(err);
process.exit(1);
} else {

@@ -82,3 +83,2 @@ if (outputFile) {

});
outputStream.end();
} else if (options.output_mode === 'list') {

@@ -88,3 +88,2 @@ results.forEach(function (result) {

});
outputStream.end();
} else if (options.output_mode === 'script') {

@@ -101,4 +100,3 @@ var i = 0;

console.error(err);
} else {
outputStream.end();
process.exit(1);
}

@@ -105,0 +103,0 @@ });

var async = require('async'),
TokenStream = require('./TokenStream'),
fs = require('fs'),
glob = require('glob'),
utils = require('./utils'),
path = require('path');
var findJS = function (path, callback) {
utils.walkdir(path, function (file) {
return /.*\.js$/i.test(file);
}, callback);
var findJS = function (p, callback) {
glob('**/*.js', { cwd: p }, function (err, result) {
if (err) {
callback(err);
} else {
callback(err, result.map(function (f) {
return path.join(p, f);
}));
}
});
};

@@ -159,3 +166,3 @@

callback(null, results.filter(function (dependency) {
dependency.relativePath = relativePath(base.path, dependency.path);
dependency.relativePath = utils.relativePath(base.path, dependency.path);
return !dependency.base && !excludeSet[dependency.path];

@@ -162,0 +169,0 @@ }));

@@ -40,127 +40,6 @@ var async = require('async'),

/**
* The code below is taken from Node 0.5.4 because 0.4.x does not have this function
* License below applies.
*/
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
// path.relative(from, to)
// posix version
module.exports.relative = function(from, to) {
from = path.resolve(from).substr(1);
to = path.resolve(to).substr(1);
function trim(arr) {
var start = 0;
for (; start < arr.length; start++) {
if (arr[start] !== '') break;
}
var end = arr.length - 1;
for (; end >= 0; end--) {
if (arr[end] !== '') break;
}
if (start > end) return [];
return arr.slice(start, end - start + 1);
}
var fromParts = trim(from.split('/'));
var toParts = trim(to.split('/'));
var length = Math.min(fromParts.length, toParts.length);
var samePartsLength = length;
for (var i = 0; i < length; i++) {
if (fromParts[i] !== toParts[i]) {
samePartsLength = i;
break;
}
}
var outputParts = [];
for (var i = samePartsLength; i < fromParts.length; i++) {
outputParts.push('..');
}
outputParts = outputParts.concat(toParts.slice(samePartsLength));
return outputParts.join('/');
};
/**
* Returns the relative from file `from` to file `to`.
*/
module.exports.relativePath = function (from, to) {
return directoryUtils.relative(path.dirname(from) + '/', to);
}
function walkdir(dir, filterFn, callback) {
fs.lstat(dir, function (err, stat) {
if (err) {
callback(err);
} else if (stat.isDirectory()) {
fs.readdir(dir, function (err, files) {
if (err) {
callback(err);
} else {
async.concat(files, function (file, callback) {
var p = path.join(dir, file);
fs.lstat(p, function (err, stat) {
if (err) {
callback(err);
} else {
callback(err, {
path: path.resolve(p),
isDirectory: stat.isDirectory()
});
}
});
}, function (err, stats) {
if (err) {
callback(err);
} else {
async.filter(stats, function (stat, callback) {
callback(stat.isDirectory || filterFn(stat.path));
}, function (stats) {
async.concat(stats, function (stat, callback) {
if (stat.isDirectory) {
walkdir(stat.path, filterFn, callback);
} else {
callback(null, stat.path);
}
}, callback);
});
}
});
}
});
} else if (filterFn(dir)) {
callback(null, [dir]);
} else {
callback(null, []);
}
});
};
module.exports.walkdir = walkdir;
return path.relative(path.dirname(from) + '/', to);
}

@@ -5,3 +5,3 @@ {

"description": "A Node.js port of Google Closure library calcdeps.py",
"version": "0.1.2",
"version": "0.1.4",
"keywords": ["calcdeps.py", "closure", "closure compiler", "calcdeps"],

@@ -20,3 +20,4 @@ "repository": {

"async": ">=0.1.9",
"optimist": ">=0.2.6"
"optimist": ">=0.2.6",
"glob": "3.1.9"
},

@@ -23,0 +24,0 @@ "devDependencies": {

@@ -27,65 +27,3 @@ var vows = require('vows'),

}
},
'walkdir - all files': {
topic: function () {
utils.walkdir('./test/data', function () {
return true;
}, this.callback);
},
'did not return an error': function (err, result) {
assert.isNull(err);
},
'found five files': function (err, result) {
assert.lengthOf(result, 5);
}
},
'walkdir - *.js filter': {
topic: function () {
utils.walkdir('./test/data', function (file) {
return /.*\.js$/i.test(file);
}, this.callback);
},
'did not return an error': function (err, result) {
assert.isNull(err);
},
'found four *.js files': function (err, result) {
assert.lengthOf(result, 4);
}
},
'walkdir - nonexistent dir': {
topic: function () {
utils.walkdir('nope', function () {
return true;
}, this.callback);
},
'returned error': function (err, result) {
assert.isNotNull(err);
}
},
'walkdir - not a dir': {
topic: function () {
utils.walkdir('./test/data/README.md', function () {
return true;
}, this.callback);
},
'did not return an error': function (err, result) {
assert.isNull(err);
},
'found one file': function (err, result) {
assert.lengthOf(result, 1);
}
},
'walkdir - not a dir and excluded': {
topic: function () {
utils.walkdir('./test/data/README.md', function (file) {
return /.*\.js$/i.test(file);
}, this.callback);
},
'did not return an error': function (err, result) {
assert.isNull(err);
},
'returned an empty result': function (err, result) {
assert.isEmpty(result);
}
}
}).export(module);
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