fast-extract
Version:
Extract contents from various archive types (tar, tar.bz2, tar.gz, tar.xz, tgz, zip)
15 lines (14 loc) • 604 B
JavaScript
import getBasename from './basename.js';
import getSize from './size.js';
export default function sourceStats(source, options, endpoint, callback) {
const cb = typeof endpoint === 'function' ? endpoint : callback;
const ep = typeof endpoint === 'function' ? undefined : endpoint;
getSize(source, options, (err, size)=>{
if (err) return cb(err);
const stats = {};
const basename = getBasename(source, options, ep);
if (basename !== undefined) stats.basename = basename;
if (size !== undefined) stats.size = size;
cb(undefined, stats);
});
}