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

antr

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

antr - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

25

lib/helper.js

@@ -26,3 +26,28 @@ var fs = require('fs');

});
},
strRepeat: function(str, length){
var out = '';
for( var x=0; x<length; x++){
out += str;
}
return out;
},
concatArray: function (arrays) { // res == array of array
for(var a in arrays) {
if (a == 0) {
if(arrays[a] instanceof Array) {
var arr = arrays[a];
} else {
var arr = [ arrays[a] ]
}
} else {
if(arrays[a] instanceof Array) {
arr = arr.concat(arrays[a])
} else {
arr.push(arrays[a]);
}
}
}
return arr;
}
}

8

lib/Reporter.js
var sty = require('sty');
var str = require('./strUtilities');
var helper = require('./helper');

@@ -34,3 +34,3 @@ function Reporter(options){

console.log(sty.yellow('\n' + 'node ' + file + '\n' + str.repeat('=', file.length + 5)));
console.log(sty.yellow('\n' + 'node ' + file + '\n' + helper.strRepeat('=', file.length + 5)));
output.forEach(function(line){ // Write each line from the child process

@@ -69,3 +69,3 @@ console.log(sty.bold(line.data));

var spaces = str.repeat(' ', this._lastLine.length);
var spaces = helper.strRepeat(' ', this._lastLine.length);

@@ -118,5 +118,5 @@ process.stdout.write('\r' + spaces + '\r');

var chunks = Math.floor(percent / 5);
return ' [' + str.repeat('=', chunks - 1) + '>' + str.repeat('-', 20 - chunks) + ']';
return ' [' + helper.strRepeat('=', chunks - 1) + '>' + helper.strRepeat('-', 20 - chunks) + ']';
}
module.exports = Reporter;

@@ -113,3 +113,15 @@ var async = require('async');

var self = this;
helper.walk(this._options.dirname, function (err, files) {
var dirs = ( this._options.dirname instanceof Array ) ? this._options.dirname : [this._options.dirname];
async.map(dirs, this.findFiles.bind(this), function(err, results){
var files = helper.concatArray(results);
if( self._options.listFiles ) console.log('Files going to be run: ', files);
cb(null, files);
});
}
Antr.prototype.findFiles = function(dir, cb){
var self = this;
helper.walk(dir, function (err, files) {
if( err ) return cb(err, null);

@@ -120,3 +132,2 @@ async.filter(files, function (item, callback) {

}, function (filteredFiles) {
if( self._options.listFiles ) console.log('Files going to be run: ', filteredFiles);
cb(null, filteredFiles);

@@ -123,0 +134,0 @@ });

@@ -9,3 +9,3 @@ {

],
"version": "0.0.3",
"version": "0.1.0",
"dependencies": {

@@ -12,0 +12,0 @@ "async": "0.2.7",

@@ -11,3 +11,3 @@ #antr

##Install
npm install antr
npm install antr

@@ -49,7 +49,8 @@ ##Usage

##### Optional
* **dirname** Directory to find files in - defaults to `.`
#### Optional
* **dirname** Directory to find files in - defaults to `.` *This can be an array of directories*
* **listFiles** Print out the array of files which will be run - defaults to `false`
* **timeout** A timeout, in seconds, for each test - defaults to `30`
* **batchSize** Maximum amount of concurrent tests to run - defaults to `8`
* **progressBar** Option to display a progress bar - defaults to `true`

@@ -56,0 +57,0 @@ ## npm Maintainers

@@ -11,3 +11,3 @@ var Antr = require('../../');

timeout: 5,
batchSize: 2
batchSize: 5
}, function (err, stats) {

@@ -14,0 +14,0 @@ assert.equal(2, stats.failed);

@@ -5,3 +5,3 @@ var helper = require('../../lib/helper');

(function(){
(function(){ // test walk helper function
helper.walk('test/files', function(err, files){

@@ -16,3 +16,26 @@ var testFiles = [

assert.deepEqual(difference, []);
})
});
})();
(function(){ // test strRepeat helper function
var dumStr = '1111111111';
var repStr = helper.strRepeat('1', 10);
assert.equal(dumStr, repStr);
assert.equal(repStr.length, 10);
})();
(function() { // test concatArray helper function
var before = [
[ 0, 1, 2, 3 ],
[ 4, 5, 6, 7 ],
[ 8, 9, 10, 11 ],
[ 12, 13, 14, 15 ]
];
var after = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ];
assert.deepEqual(helper.concatArray(before), after);
assert.deepEqual(helper.concatArray([0, 1, 2]), [0, 1, 2]);
assert.deepEqual(helper.concatArray([[0, 1, 2]]), [0, 1, 2]);
})();

@@ -6,3 +6,3 @@ var Runner = require('../../lib/Runner.js');

var runner = new Runner({
dirname: 'test/files',
dirname: ['test/unit', 'test/files'],
filter: /run([^\/w]+?)\.js$/

@@ -36,2 +36,11 @@ });

runner._options.dirname = 'test/files'; // Change to using a non array of directories
// Test the file finder and filter is working properly
runner.getFiles(function(err, files){
var testFiles = [
'test/files/runMe.js'
];
assert.deepEqual(files, testFiles);
})
// Do the assertions!

@@ -43,2 +52,3 @@ assert.equal(runner._stats.passed, 1);

assert.equal(runner._stats.timeTaken, 10);
})();
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