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

fs-cli

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

fs-cli - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

37

index.js

@@ -17,3 +17,4 @@ /*jshint esnext: true */

var fs = require('fs');
var tgz = require('tar.gz');
var tarball = require('tar-fs');
var gunzip = require('gunzip-maybe');
var Zip = require('adm-zip');

@@ -59,2 +60,3 @@ var glob = require('glob');

* @param {Stream} write
* @param {string} [closeEvent] - close event name to watch, default 'close'
* @returns {{ err: {Error}, done: {boolean} }}

@@ -64,3 +66,3 @@ * @access private

*/
function pipeSync (read, write) {
function pipeSync (read, write, closeEvent) {
'use strict';

@@ -71,2 +73,4 @@

closeEvent = closeEvent || 'close';
read.on('error', function (e) {

@@ -91,3 +95,3 @@ err = e;

write.on('close', function (e) {
write.on(closeEvent, function (e) {
err = e;

@@ -794,5 +798,6 @@ done = true;

var dir = p.dirname(dst);
var stat = exists(src);
var existingSrc = exists(src);
var root = '';
if (!stat) {
if (!existingSrc) {
lastError = new Error('Tar error: source path "' + src +

@@ -807,4 +812,13 @@ '" does not exists!');

if (existingSrc.isDirectory()) {
root = p.basename(src) + '/';
}
return pipeSync(
tgz().createReadStream(src),
tarball.pack(src, {
map: function (header) {
header.name = root + header.name;
return header;
}
}).pipe(gunzip()),
fs.createWriteStream(dst)

@@ -831,5 +845,5 @@ );

var dir = p.dirname(dst);
var stat = exists(src);
var existingSrc = exists(src);
if (!stat) {
if (!existingSrc) {
lastError = new Error('Untar error: source path "' + src +

@@ -845,4 +859,5 @@ '" does not exists!');

return pipeSync(
fs.createReadStream(src),
tgz().createWriteStream(dst)
fs.createReadStream(src).pipe(gunzip()),
tarball.extract(dst),
'finish'
);

@@ -1260,2 +1275,4 @@ }

relpath: relpath,
basename: p.basename,
dirname: p.dirname,
glob: glob.sync,

@@ -1262,0 +1279,0 @@ DIRSEP: SEP,

{
"name": "fs-cli",
"version": "0.0.2",
"version": "0.0.3",
"description": "Easy filesystem functions",

@@ -13,3 +13,4 @@ "main": "index.js",

"generate-docs": "jsdoc -c .jsdocrc --verbose",
"jscheck": "jshint index.js && jscs index.js"
"jscheck": "jshint index.js cover.js && jscs index.js cover.js",
"prepublish": "npm run jscheck && npm test && npm run generate-docs"
},

@@ -21,8 +22,10 @@ "license": "ISC",

"glob": "^6.0.1",
"tar.gz": "^1.0.2"
"gunzip-maybe": "^1.2.1",
"tar-fs": "^1.8.1"
},
"devDependencies": {
"loke-jsdoc-theme": "^2.1.0",
"mocha": "^2.3.4"
"mocha": "^2.3.4",
"tar-stream": "^1.3.1"
}
}

@@ -85,3 +85,5 @@ # Easy FS Scripting With NodeJS

- **exists**: checks if exists, return file system object stats if exists
- **relpath/realpath**: paths transform, cross-platform, exists-free
- **relpath/realpath**: paths transform, cross-platform, exists-free
- **basename/dirname**: aliases for native path.basename/path.dirname
- **glob**: alias for glob.sync

@@ -88,0 +90,0 @@ ## Want More?

var assert = require('assert');
var fs = require('../index');
var tgz = require('tar.gz');
var tar = require('tar-stream');
var gunzip = require('gunzip-maybe');
var nfs = require('fs');
var p = require('path');

@@ -15,3 +17,3 @@

it('should create zip archive', function () {
it('should create gzipped tarball', function () {
assert.equal(fs.tar(src, dst), true);

@@ -28,16 +30,18 @@ assert.equal(!!fs.exists(dst), true);

it('should contain certain file', function (done) {
var extract = tar.extract();
var found = false;
var read = require('fs').createReadStream(dst);
var parse = tgz().createParseStream();
var thisFile = p.basename(__filename);
parse.on('entry', function(entry){
var entryFile = p.basename(entry.path);
if (entryFile == thisFile) {
extract.on('entry', function (header, stream, next) {
if (header.name == 'test/tar.js') {
found = true;
stream.end();
extract.end();
done();
}
stream.on('end', next);
stream.resume();
});
parse.on('close', function () {
extract.on('finish', function () {
assert.equal(found, true);

@@ -47,3 +51,5 @@ done();

read.pipe(parse);
nfs.createReadStream('./tmp/test.tgz')
.pipe(gunzip())
.pipe(extract);
});

@@ -50,0 +56,0 @@

@@ -15,14 +15,6 @@ var assert = require('assert');

});
/**
* Currenty there is some strange behavior of tar.gz library
* At least on Windows its write stream fires "close" event, but
* as may be seen from this test writing the files to disk
* is not actually finished! This requires for further deeper investigation
* or maybe own implementation of packing/unpacking tarballs
* @TODO: investigate and fix tar/untar behavior
*/
/*it('destination should have correct list of files', function () {
it('destination should have correct list of files', function () {
assert.deepEqual(fs.ls('./test').sort(), fs.ls('./tmp/test').sort());
assert.equal(fs.error(), null);
});*/
});

@@ -29,0 +21,0 @@ after(function() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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