Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pack.on('close', function() {
try {
var packageArchive = path.join(tempDir, packageName);
fs.createReadStream(packageArchive).pipe(zlib.createGunzip()).pipe(tar.extract(tempDir)).on('finish', function() {
fs.removeSync(packageArchive) // remove the pack archive so it doesn't show up in the proxy
if (opts.debug) {
console.log('bundled dependencies ready for upload')
}
// return path to packed directory
return cb(undefined, path.join(tempDir, 'package'))
}).on('error', function(err) {
return cb(err);
});
} catch(err) {
return cb(err)
}
});
});
process(proc, resolve, reject, done) {
const extractor = tarFs.extract(dest, {
dmode: 0o555, // all dirs should be readable
fmode: 0o444 });
extractor.on('error', reject);
extractor.on('finish', done);
proc.stdout.pipe(extractor);
}
});
process(proc, update, reject, done) {
const extractor = tarFs.extract(dest, {
dmode: 0o555, // all dirs should be readable
fmode: 0o444, // all files should be readable
});
extractor.on('error', reject);
extractor.on('finish', done);
proc.stdout.pipe(extractor);
proc.on('error', reject);
},
});
const extractAsset = async (savePath, extractDir, onProgress) => {
log.info('Extracting asset:', savePath);
const start = Date.now();
const extract = tarStream.extract();
const { size } = await fs.statAsync(savePath);
const result = await pump(
// eslint-disable-next-line security/detect-non-literal-fs-filename
fs.createReadStream(savePath),
createProgressStream(size, onProgress),
lzma.createDecompressor(),
tar.extract(extractDir, {
fs,
extract,
fmode: 0o600,
dmode: 0o700,
}),
);
const elapsed = Date.now() - start;
log.info('Asset extracted:', savePath, `(took ${prettyMs(elapsed)})`);
return result;
};
export async function prepareBuilderDir() {
const builderDir = join(await cacheDirPromise, 'builders');
await mkdirp(builderDir);
// Extract the bundled `builders.tar.gz` file, if necessary
const bundledTarballPath = join(__dirname, '../../../assets/builders.tar.gz');
const existingPackageJson =
(await readFileOrNull(join(builderDir, 'package.json'), 'utf8')) || '{}';
const { dependencies = {} } = JSON.parse(existingPackageJson);
if (!hasBundledBuilders(dependencies)) {
const extractor = extract(builderDir);
await pipe(
createReadStream(bundledTarballPath),
createGunzip(),
extractor
);
}
return builderDir;
}
var receive = function () {
var stream = airpaste(opts.namespace)
var ignore = function (name) {
if (!opts.o && fs.existsSync(name) && fs.statSync(name).isFile()) {
console.log(chalk.red('[ EXISTS ]') + ' ' + name)
return true
}
return false
}
var dir = opts._[0] || process.cwd()
var found = wait('waiting for sender', dir)
var count = counter()
var target = tarfs.extract(dir, { ignore: ignore, mapStream: measure })
stream.once('uncork', function () {
found()
stream
.pipe(count.through)
.pipe(target)
})
target.once('finish', function () {
console.log(chalk.gray(prettysize(count.total()) + ' received'))
})
}
var stripLevel = 0;
if ('MacOS64' === platform || this.nodeWebkitVersion.indexOf('v0.9.') === -1 && this.nodeWebkitVersion.indexOf('v0.8.') === -1) {
stripLevel = 1;
}
unzipper.extract({
path: 'resources/node-webkit/' + platform,
strip: stripLevel
});
} else {
defer.resolve();
}
} else if ('.tar.gz' === extension) {
this.log.info('Un.tar.gz %s files.', platform);
var src = 'tmp/' + platform + extension;
var dst = 'resources/node-webkit/' + platform;
fs.createReadStream(src).pipe(zlib.createGunzip()).pipe(tar.extract(dst)).on('finish', function (error) {
if (!error) {
var platformSuffix = platform === 'Linux64' ? '-linux-x64' : '-linux-ia32';
var namePart = '/nwjs-';
if (_this.nodeWebkitVersion.indexOf('v0.9.') !== -1 || _this.nodeWebkitVersion.indexOf('v0.8.') !== -1 || _this.nodeWebkitVersion.indexOf('v0.10.') !== -1 || _this.nodeWebkitVersion.indexOf('v0.11.') !== -1) {
namePart = '/node-webkit-';
}
var copyPath = 'resources/node-webkit/' + platform + namePart + _this.nodeWebkitVersion + platformSuffix;
fs.copy(copyPath, 'resources/node-webkit/' + platform, function(error) {
if (error) {
defer.reject(error);
} else {
fs.remove(copyPath);
_this.log.ok('%s directory successfully copied.', platform);
defer.resolve();
}
});
return new Promise((resolve, reject) => {
const extract = tar.extract(cwd, { strip: 1 })
extract.on('finish', () => {
resolve()
})
request.get(options)
.pipe(gunzip())
.pipe(extract)
.on('error', reject)
})
}
return new Promise((resolve, reject) => {
function map(header) {
header.name = getFileName(header.name, virtualPath) || header.name;
return header;
}
let gunzipper = gunzipMaybe();
let extractor = tarFs.extract(target, { map });
gunzipper.pipe(extractor);
extractor.on(`error`, error => {
reject(error);
});
extractor.on(`finish`, () => {
resolve();
});
gunzipper.write(packageBuffer);
gunzipper.end();
});
};
var onerror = function(err) {
onend({type:'error', message:err.message});
};
var onend = function(message) {
status.write(message || {type:'success'});
status.end();
plex.end();
};
status.pipe(plex.createStream(1));
plex.pipe(response);
pump(request, zlib.createGunzip(), tar.extract(cwd), function(err) {
if (err) return onextracterror(err);
if (!db.has(id)) return onextracterror(new Error('service not found'));
var service = db.get(id);
var onready = function() {
if (!db.has(id)) return onextracterror(new Error('service not found'));
service = db.get(id);
service.deployed = deployed;
service.cwd = cwd;
db.put(id, service, function(err) {
if (err) return onextracterror(err);
ondistribute();
});