Comparing version 0.2.2 to 0.2.3
@@ -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']; |
{ | ||
"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(); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
10638
301
3
+ Addedtar@^2.2.1
- Removedtar.gz@1.0.2
- Removedassertion-error@1.1.0(transitive)
- Removedbluebird@2.11.0(transitive)
- Removedchai@3.5.0(transitive)
- Removedcommander@0.6.12.3.0(transitive)
- Removeddebug@2.2.0(transitive)
- Removeddeep-eql@0.1.3(transitive)
- Removeddiff@1.4.0(transitive)
- Removedescape-string-regexp@1.0.2(transitive)
- Removedglob@3.2.11(transitive)
- Removedgrowl@1.9.2(transitive)
- Removedjade@0.26.3(transitive)
- Removedlru-cache@2.7.3(transitive)
- Removedminimatch@0.3.0(transitive)
- Removedminimist@0.0.8(transitive)
- Removedmkdirp@0.3.00.5.1(transitive)
- Removedmocha@2.5.3(transitive)
- Removedmout@0.11.1(transitive)
- Removedms@0.7.1(transitive)
- Removedsigmund@1.0.1(transitive)
- Removedsupports-color@1.2.0(transitive)
- Removedtar.gz@1.0.2(transitive)
- Removedto-iso-string@0.0.2(transitive)
- Removedtype-detect@0.1.11.0.0(transitive)