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

atool-pack

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

atool-pack - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

29

lib/extract.js

@@ -7,4 +7,10 @@ 'use strict';

var _tar = require('tar.gz');
var _fs = require('fs');
var _zlib = require('zlib');
var _zlib2 = _interopRequireDefault(_zlib);
var _tar = require('tar');
var _tar2 = _interopRequireDefault(_tar);

@@ -15,7 +21,22 @@

exports.default = function (filename, dir) {
return (0, _tar2.default)(null, {
strip: 1
}).extract(filename, dir);
return new Promise(function (resolve, reject) {
var stream = (0, _fs.createReadStream)(filename);
var gunzip = _zlib2.default.createGunzip();
gunzip.on('error', function (err) {
return reject(err);
});
var extracter = _tar2.default.Extract({
path: dir,
strip: 1
});
extracter.on("error", function (err) {
return reject(err);
});
extracter.on("end", function () {
return resolve();
});
stream.pipe(gunzip).pipe(extracter);
});
};
module.exports = exports['default'];

4

package.json
{
"name": "atool-pack",
"version": "0.2.2",
"version": "0.2.3",
"description": "npm pack and extract",

@@ -25,3 +25,3 @@ "homepage": "http://github.com/ant-tool/atool-pack",

"shelljs": "^0.6.0",
"tar.gz": "1.0.2"
"tar": "^2.2.1"
},

@@ -28,0 +28,0 @@ "devDependencies": {

@@ -1,7 +0,16 @@

import targz from 'tar.gz';
export default (filename, dir) => {
return targz(null, {
import { createReadStream } from 'fs';
import zlib from 'zlib';
import tar from 'tar';
export default (filename, dir) => new Promise((resolve, reject) => {
const stream = createReadStream(filename)
const gunzip = zlib.createGunzip()
gunzip.on('error', err => reject(err));
const extracter = tar.Extract({
path: dir,
strip: 1,
}).extract(filename, dir);
};
});
extracter.on("error", err => reject(err));
extracter.on("end", () => resolve());
stream.pipe(gunzip).pipe(extracter);
});

@@ -6,4 +6,6 @@ import pack from '../src';

import { assert } from 'chai';
import { readFileSync } from 'fs';
describe('atool-pack', () => {
describe('atool-pack', function() {
this.timeout(0);

@@ -20,5 +22,12 @@ const dir = join(__dirname, 'test');

it('pack success' , function(done) {
this.timeout(0);
pack('rcf', dir).then(() => {
done();
});
const content = readFileSync(join(dir, 'lib/index.js'));
if (content) {
done();
} else {
done('err')
}
}).catch(err => console.log(err));
});

@@ -34,10 +43,2 @@

it('pack file' , function(done) {
pack('rcf', dir).then(() => {
const pkg = require(join(dir, 'package.json'));
assert(pkg.name === 'rcf')
done();
});
});
});
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