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

bal-util

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bal-util - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

2

package.json
{
"name": "bal-util",
"version": "0.2.0",
"version": "0.2.1",
"description": "Common utility functions for Node.js used and maintained by Benjamin Lupton",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/balupton/bal-util.npm",

@@ -39,3 +39,3 @@ # Balupton's Node.js Utility Functions

- v0.2 May 20, 2011
- Added some tests with Vows
- Added some tests with expresso
- util.scandir now returns err,list,tree

@@ -42,0 +42,0 @@ - Added util.writetree

@@ -1,2 +0,1 @@

var vows = require('vows');
var assert = require('assert');

@@ -10,2 +9,3 @@ var coffee = require('coffee-script');

outPath = __dirname+'/out',
nonPath = __dirname+'/asd',
writetree = {

@@ -44,99 +44,93 @@ 'index.html': '<html>',

vows.describe('bal-util/util').addBatch({
'writetree': {
topic: function(){
util.writetree(
// Path
srcPath,
// Tree
writetree,
// Complete
this.callback
);
},
'did not error': function(err){
assert.equal(err,false);
},
'scandir': {
topic: function() {
callback = this.callback;
util.scandir(srcPath,false,false,function(err,list,tree){
callback(null,err,list,tree);
});
},
'did not error': function(z,err,list,tree){
assert.equal(err,false);
},
'files were written': function(z,err,list,tree){
assert.deepEqual(tree,scantree);
},
'cpdir': {
topic: function(){
callback = this.callback;
util.cpdir(srcPath,outPath,function(err){
callback(null,err);
});
},
'did not error': function(z,err,list,tree){
assert.equal(err,false);
},
'scandir': {
topic: function() {
callback = this.callback;
util.scandir(srcPath,false,false,function(err,list,tree){
callback(null,err,list,tree);
// Tests
var tests = {
'writetree': function(beforeExit){
var nTests = 6, nTestsCompleted = 0;
// writetree
util.writetree(srcPath,writetree,function(err){
++nTestsCompleted;
// no error
assert.equal(err||false,false, 'writetree: no error');
// scandir
util.scandir(srcPath,false,false,function(err,list,tree){
++nTestsCompleted;
// no error
assert.equal(err||false,false, 'writetree: scandir: no error');
// files were written
assert.deepEqual(tree,scantree, 'writetree: scandir: files were written');
// cpdir
util.cpdir(srcPath,outPath,function(err){
++nTestsCompleted;
// no error
assert.equal(err||false,false, 'writree: scandir: cpdir: no error');
// scandir
util.scandir(srcPath,false,false,function(err,list,tree){
++nTestsCompleted;
// no error
assert.equal(err||false,false, 'writree: scandir: cpdir: scandir: no error');
// files were copied
assert.deepEqual(tree,scantree, 'writree: scandir: cpdir: scandir: files were copied');
// rmdir
util.rmdir(srcPath,function(err){
++nTestsCompleted;
// no error
assert.equal(err||false,false, 'writree: scandir: cpdir: scandir: rmdir: no error');
// dir was deleted
var exists = path.existsSync(srcPath);
assert.equal(exists,false, 'writree: scandir: cpdir: scandir: rmdir: delete successful');
});
},
'did not error': function(z,err,list,tree){
assert.equal(err,false);
},
'files were copied': function(z,err,list,tree){
assert.deepEqual(tree,scantree);
},
'rmdir-src': {
topic: function(){
callback = this.callback;
util.rmdir(srcPath,function(err){
console.log('Ignore the error about to happen, as seeing this proves the callback did fire');
callback(null,err);
});
},
'did not error': function(z,err){
assert.equal(err||false,false);
},
'path.exists': function(){
var exists = path.existsSync(srcPath);
assert.equal(exists,false);
}
},
'rmdir-out': {
topic: function(){
callback = this.callback;
util.rmdir(outPath,function(err){
callback(null,err);
});
},
'did not error': function(z,err){
assert.equal(err||false,false);
},
'path.exists': function(){
// rmdir
util.rmdir(outPath,function(err){
++nTestsCompleted;
// no error
assert.equal(err||false,false, 'writree: scandir: cpdir: scandir: rmdir: no error');
// dir was deleted
var exists = path.existsSync(outPath);
assert.equal(exists,false);
}
}
}
}
}
assert.equal(exists,false, 'writree: scandir: cpdir: scandir: rmdir: delete successful');
});
});
});
});
});
// async
beforeExit(function(){
assert.equal(nTests, nTestsCompleted, 'all writetree tests ran');
});
},
'rmdir-non': function(beforeExit){
var nTests = 1, nTestsCompleted = 0;
// rmdir
util.rmdir(nonPath,function(err){
++nTestsCompleted;
// no error
assert.equal(err||false,false, 'rmdir-non: no error');
});
// async
beforeExit(function(){
assert.equal(nTests, nTestsCompleted, 'all rmdir tests ran');
});
}
}).export(module);
};
function assertError(assertion, value, fail) {
try {
assertion(value);
fail = true;
} catch (e) {/* Success */}
fail && assert.fail(value, assert.AssertionError,
'expected an AssertionError for {actual}',
'assertError', assertError);
}
// Export
module.exports = tests;
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