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

sander

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sander - npm Package Compare versions

Comparing version 0.2.4 to 0.3.0

.babelrc

5

CHANGELOG.md
# changelog
## 0.3.0
* Rewrote as ES6 modules
* Added `symlinkOrCopy` and `symlinkOrCopySync` methods, inspired by [symlink-or-copy](https://github.com/broccolijs/node-symlink-or-copy)
## 0.2.4

@@ -4,0 +9,0 @@

16

package.json

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

"author": "Rich Harris",
"version": "0.2.4",
"version": "0.3.0",
"license": "MIT",

@@ -15,9 +15,17 @@ "repository": "https://github.com/rich-harris/sander",

},
"main": "lib/index.js",
"main": "dist/sander.js",
"jsnext:main": "src/sander.js",
"devDependencies": {
"buffer-crc32": "^0.2.3"
"buffer-crc32": "^0.2.3",
"gobble": "^0.9.2",
"gobble-babel": "^5.1.0",
"gobble-cli": "^0.4.1",
"gobble-esperanto-bundle": "^0.1.7",
"mocha": "^2.2.4"
},
"scripts": {
"test": "node test/index.js"
"test": "mocha",
"build": "gobble build -f dist",
"prepublish": "npm run build; npm test"
}
}

@@ -182,2 +182,7 @@ # sander

sander.rimrafSync(...paths)
// Symlink a file or directory, unless we're on Windows in which
// case fall back to copying to avoid permissions issues
sander.symlinkOrCopy(...paths).to(...paths);
sander.symlinkOrCopySync(...paths).to(...paths);
```

@@ -184,0 +189,0 @@

@@ -9,23 +9,55 @@ var fs = require( 'fs' );

sander.rimrafSync( 'output' );
describe( 'sander', function () {
beforeEach( function () {
return sander.rimraf( 'output' );
});
tests = [
{
name: 'copydir',
test: function () {
return sander.copydir( 'input', 'dir' ).to( 'output', '1' ).then( function () {
checkEquality([ 'input', 'dir' ], [ 'output', '1' ]);
describe( 'readFile', function () {
it( 'reads a file', function () {
return sander.readFile( 'input', 'dir', 'text.txt' )
.then( String )
.then( function ( data ) {
assert.equal( data, fs.readFileSync( 'input/dir/text.txt', 'utf-8' ) );
});
});
it( 'reads a file synchronously', function () {
var data = sander.readFileSync( 'input', 'dir', 'text.txt' ).toString();
assert.equal( data, fs.readFileSync( 'input/dir/text.txt', 'utf-8' ) );
});
it( 'reads a file with encoding', function () {
return sander.readFile( 'input', 'dir', 'text.txt', { encoding: 'utf-8' })
.then( function ( data ) {
assert.equal( data, fs.readFileSync( 'input/dir/text.txt', 'utf-8' ) );
});
});
it( 'reads a file synchronously with encoding', function () {
var data = sander.readFileSync( 'input', 'dir', 'text.txt', { encoding: 'utf-8' });
assert.equal( data, fs.readFileSync( 'input/dir/text.txt', 'utf-8' ) );
});
});
describe( 'copydir', function () {
it( 'copies a directory', function () {
return sander.copydir( 'input', 'dir' ).to( 'output' ).then( function () {
checkEquality([ 'input', 'dir' ], [ 'output' ]);
});
}
},
});
{
name: 'appendFile',
test: function () {
return sander.writeFile( 'output/2/test.txt', 'first line' )
it( 'copies a directory synchronously', function () {
sander.copydirSync( 'input', 'dir' ).to( 'output' );
checkEquality([ 'input', 'dir' ], [ 'output' ]);
});
});
describe( 'appendFile', function () {
it( 'appends to a file', function () {
return sander.writeFile( 'output/test.txt', 'first line' )
.then( function () {
return sander.appendFile( 'output/2/test.txt', '\nsecond line' )
return sander.appendFile( 'output/test.txt', '\nsecond line' )
})
.then( function () {
return sander.readFile( 'output/2/test.txt' )
return sander.readFile( 'output/test.txt' )
.then( String )

@@ -36,30 +68,40 @@ .then( function ( combined ) {

});
}
}
];
});
runNextTest();
it( 'appends to a file synchronously', function () {
sander.writeFileSync( 'output/test.txt', 'first line' );
sander.appendFileSync( 'output/test.txt', '\nsecond line' );
function runNextTest () {
var test = tests.shift(),
promise;
var combined = sander.readFileSync( 'output/test.txt' ).toString();
assert.equal( combined, 'first line\nsecond line' );
});
});
if ( !test ) {
console.log( 'done' );
return;
}
describe( 'symlinkOrCopy', function () {
it( 'symlinks a directory', function () {
return sander.symlinkOrCopy( 'input', 'dir' ).to( 'output' )
.then( function () {
var stats = fs.statSync( 'output' );
assert.ok( stats.isDirectory() );
promise = test.test();
var lstats = fs.lstatSync( 'output' );
assert.ok( lstats.isSymbolicLink() );
});
});
if ( promise && typeof promise.then === 'function' ) {
promise.then( runNextTest ).catch( function ( err ) {
setTimeout( function () {
throw err;
});
it( 'symlinks a directory synchronously', function () {
sander.symlinkOrCopySync( 'input', 'dir' ).to( 'output' );
var stats = fs.statSync( 'output' );
assert.ok( stats.isDirectory() );
var lstats = fs.lstatSync( 'output' );
assert.ok( lstats.isSymbolicLink() );
});
} else {
runNextTest();
}
}
// TODO override environment so that it thinks we're in Windows and copies instead...
});
});
function checkEquality ( a, b ) {

@@ -66,0 +108,0 @@ var statsA, statsB, filesA, filesB, crcA, crcB;

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