Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pack.finalize();
});
tarballStream.on('error', console.error).pipe(extract);
return pack;
};
function inspect(obj, depth) {
console.error(require('util').inspect(obj, false, depth || 5, true));
}
// Test
if (!module.parent && typeof window === 'undefined') {
var dir = path.join(__dirname, '..', 'tmp');
var resdir = path.join(__dirname, '..', 'result');
var pack = tar.pack();
var extract = tar.extract();
var gunzip = require('zlib').createGunzip();
var ins = fs.createReadStream(dir + '/in.tar.gz', 'utf8').pipe(gunzip);
go(ins, true)
.on('error', console.error)
.pipe(fs.createWriteStream(resdir + '/out.tar', 'utf8'));
}
EmberTranslator.prototype.startTranslation = function (inputPath, outputPath) {
// create the tar -> gzip -> file stream
this.fstream = fs.createWriteStream( outputPath );
this.gzip = zlib.createGzip();
this.pack = tar.pack();
this.gzip.pipe( this.fstream );
this.pack.pipe( this.gzip );
// write the settings
this.writeSettings();
return DLPTranslator.prototype.startTranslation.apply( this, [inputPath, outputPath] );
};
mfeed.ready(function () {
// re-pack syncfile multifeed dir into tarball
var tarPath = path.join(self._syncdir, 'osm-p2p-db.tar')
var tarSize = 0
var tcount = through(function (chunk, _, next) { tarSize += chunk.length; next(null, chunk) })
// 1. create new tar.pack() stream, to be piped to fs.createWriteStream inside self._syncdir
var pack = tar.pack()
// 2. recursively walk files in self._syncdir (skip new tar file)
var rd = readdirp({root: path.join(self._syncdir, 'multifeed')})
// 3. write all to the tar file
var twrite = through.obj(function (file, _, next) {
if (file.path === 'osm-p2p-db.tar') return next()
debug('file', file.fullPath, file.stat.size)
var entry = pack.entry({ name: file.path, size: file.stat.size }, function (err) {
debug('wrote', file.path)
if (err) return next(err)
else next()
})
pump(fs.createReadStream(file.fullPath), entry)
})
async function _generateExamineResultsTarFile(
examineResults: ExamineResult[],
envMeta: DoctorMetaData
): Promise {
const pack = tar.pack(); // pack is a streams2 stream
const debugLog = await _getDebugLogAsStream();
const consumerInfo = await _getConsumerInfo();
let bitmap;
if (consumerInfo && consumerInfo.path) {
bitmap = _getBitMap(consumerInfo.path);
}
pack.entry({ name: 'env-meta.json' }, JSON.stringify(envMeta, null, 2));
pack.entry({ name: 'doc-results.json' }, JSON.stringify(examineResults, null, 2));
if (debugLog) {
pack.entry({ name: 'debug.log' }, debugLog);
}
if (bitmap) {
pack.entry({ name: '.bitmap' }, bitmap);
}
if (consumerInfo && consumerInfo.consumerConfig) {
pack.entry({ name: 'config.json' }, JSON.stringify(consumerInfo.consumerConfig.toPlainObject(), null, 4));
return new Promise(resolve => {
const { name, version } = pkgJson;
const pack = tar.pack();
for (const filePath of Object.keys(files)) {
pack.entry({ name: filePath }, files[filePath]);
}
pack.finalize();
const writer = new streams.WritableStream();
const z = zlib.createGzip();
pack
.pipe(z)
.pipe(writer)
.on('finish', () => {
const tarballName =
name.indexOf('/') < 0 ? name : name.substring(name.indexOf('/') + 1) + '-' + version + '.tgz';
const metadataUrl = `/${name}`;
let metadata = { versions: {} };
if (this._resources[metadataUrl]) {
metadata = JSON.parse(this._resources[metadataUrl].toString());
function makeTarball (files) {
let tarData = ''
const pack = tar.pack()
Object.keys(files).forEach(function (filename) {
pack.entry({
name: 'package/' + filename
}, JSON.stringify(files[filename]))
})
pack.finalize()
return BB.fromNode(cb => {
pack.on('error', cb)
pack.on('end', function () { cb(null, tarData) })
pack.on('data', function (d) { tarData += d })
})
}
function buildContext(packages, appName) {
let archive = tar.pack();
archive.entry({ name: 'Dockerfile' }, dockerfile(packages, appName));
async function archivePackages() {
for (let package of packages) {
await archivePackage(archive, package);
}
archive.finalize();
}
archivePackages();
return archive;
}
function getDefaultProject(title, dataType) {
var result = dataType === TAR_STREAM ? Tar.pack() : [];
_defaultProjects[title].forEach(function(file) {
switch(dataType) {
case TAR_STREAM:
result.entry({ name: file.path }, file.buffer);
break;
case FILE_STREAM:
result.push({
path: file.path,
stream: MemoryStream.createReadStream(file.buffer),
size: file.buffer.length
});
break;
case BUFFER:
default:
result.push(file);
function Deb () {
this.data = tar.pack()
this.control = tar.pack()
this.pkgSize = 0
this.controlFile = {}
this.filesMd5 = []
this.dirs = {}
}
import tar from 'tar-stream';
var pack = tar.pack();
pack.entry({ name: 'Dockerfile' }, `
FROM gliderlabs/alpine:3.3
CMD ["/bin/sh"]
`);
pack.finalize();
export default pack;