How to use the archiver.create function in archiver

To help you get started, we’ve selected a few archiver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dpricha89 / cloudsu / node_modules / grunt-contrib-compress / tasks / lib / compress.js View on Github external
exports.tar = function(files, done) {
    if (typeof exports.options.archive !== 'string' || exports.options.archive.length === 0) {
      grunt.fail.warn('Unable to compress; no valid archive file was specified.');
      return;
    }

    var mode = exports.options.mode;
    if (mode === 'tgz') {
      mode = 'tar';
      exports.options.gzip = true;
    }

    var archive = archiver.create(mode, exports.options);
    var dest = exports.options.archive;

    var dataWhitelist = ['comment', 'date', 'mode', 'store', 'gid', 'uid'];
    var sourcePaths = {};

    // Ensure dest folder exists
    grunt.file.mkdir(path.dirname(dest));

    // Where to write the file
    var destStream = fs.createWriteStream(dest);

    archive.on('error', function(err) {
      grunt.log.error(err);
      grunt.fail.warn('Archiving failed.');
    });
github artilleryio / chaos-lambda / lib / commands / deploy.js View on Github external
function createLambda(role, llamaFile, done) {
  var lambda = new aws.Lambda({apiVersion: '2015-03-31'});

  var archive = archiver.create('zip', {});

  var lambdaPath = path.join(__dirname, '../../lambda/index.js');
  var tmpf = tmp.fileSync();
  var tmpfStream = fs.createWriteStream(tmpf.name);
  archive.pipe(tmpfStream);
  archive.append(fs.readFileSync(lambdaPath), { name: 'index.js' });
  if (llamaFile) {
    debug('Adding real Chaosfile to lambda zip');
    llamaFile.region = process.env.AWS_REGION; // FIXME
    archive.append(new Buffer(JSON.stringify(llamaFile)), { name: 'config.json' });
  } else {
    debug('Adding a stub Chaosfile to lambda zip');
    archive.append(new Buffer(JSON.stringify({enableForASGs: []})), { name: 'config.json' });
  }
  lambdaDependencies.forEach( function (moduleName){
    archive.directory(path.join(__dirname, '..', '..', './node_modules/' + moduleName), 'node_modules/'+ moduleName);
github Midburn / spark / libs / aws-s3.js View on Github external
async streamZipDataTo(params, callback) {

        let zip = new Archiver.create('zip') //eslint-disable-line new-cap
        if (params.pipe) zip.pipe(params.pipe)

        // Set response headers
        params.pipe.writeHeader(200, {
            'Content-Type': 'application/zip',
            "Content-disposition": 'attachment; filename=camp-files.zip'
        })

        let self = this

        let fileList = await this.listBucket(params.bucket, params.prefix)
        let fileArr = fileList.Contents.map(async (file) => {
            let fileList = []
            let fileObj = await self.getObject(params.bucket, file.Key)
            let name = self.calculateFileName(file)
github johntitus / hocus / lib / deployer.js View on Github external
deployer.deployController = function( environmentConfig, controllerName, controllerConfig, directoryPath, indexCommand, isUpdate, awsCredentials, callback ){
	AWS.config.update({
		accessKeyId: awsCredentials.awsAccessKey,
		secretAccessKey : awsCredentials.awsSecretAccessKey,
		region : awsCredentials.regionName
	});
	// Create a temp folder to store the zip until upload is complete
	mkdirp.sync('./temp');	
	
	var outZip = fs.createWriteStream('./temp/lambda.zip' )

	var archive = archiver.create('zip',{});
	archive.append( indexCommand, { name: 'index.js' } );

	// Zip the controller directory, but inside the zip put it in a '/run' subdirectory.
	archive.directory('./controllers/' + controllerName, '/run' );
	archive.pipe( outZip );
	archive.finalize();
	
	outZip.on('close', function(){
		
		var lambda = new AWS.Lambda();

		var params = {
			FunctionName: 'hocus_' + environmentConfig.id + '_controller_' + controllerName,
		};

		if ( isUpdate ){
github Deathspike / mangarack / src / cli / commands / download.ts View on Github external
export async function downloadSeriesItemAsync(series: mio.IScraperSeries, seriesChapter: mio.IScraperSeriesChapter) {
  let chapterPath = shared.path.normal(series.providerName, series.title, seriesChapter.name + shared.extension.cbz);
  let chapterExists = await fs.pathExists(chapterPath);
  if (!chapterExists) {
    console.log(`Fetching ${seriesChapter.name}`);
    let chapter = archiver.create('zip', {store: true});
    let timer = new mio.Timer();
    await fs.ensureDir(path.dirname(chapterPath));
    chapter.pipe(fs.createWriteStream(chapterPath + shared.extension.tmp));
    await mio.usingAsync(seriesChapter.iteratorAsync(), async iterator => {
      try {
        await archiveAsync(chapter, iterator);
        chapter.finalize();
        await fs.rename(chapterPath + shared.extension.tmp, chapterPath);
        console.log(`Finished ${seriesChapter.name} (${timer})`);
      } catch (error) {
        await fs.unlink(chapterPath + shared.extension.tmp);
        throw error;
      } finally {
        chapter.abort();
      }
    });
github stephenplusplus / gcloud-deploy / index.js View on Github external
function createTarStream (callback) {
    var tarStream = archiver.create('tar', { gzip: true })
    tarStream.bulk([{ expand: true, cwd: pkgRoot, src: ['**', '!node_modules/**'] }])
    tarStream.finalize()
    callback(null, tarStream)
  }
github wparad / aws-architect.js / index.js View on Github external
await new Promise((resolve, reject) => {
		let zipStream = fs.createWriteStream(zipArchivePath);
		zipStream.on('close', () => resolve());

		let archive = archiver.create('zip', {});
		archive.on('error', e => reject({ Error: e }));
		archive.pipe(zipStream);
		archive.glob('**', { dot: true, cwd: tmpDir, ignore: options.zipFileName });
		archive.finalize();
	});
github sekaiamber / web-painter / app / utils / ipc / save.js View on Github external
function createZipfile(files) {
  var zip = archiver.create('zip', {});
  for (var i = 0; i < files.length; i++) {
    var file = files[i]
    zip.append(file.data, {'name': file.name});
  }
  return zip;
}
github aws / awsmobile-cli / lib / aws-operations / mobile-api-content-generator.js View on Github external
let tempContentYmlFilePath = pathManager.getBackendBuildYamlFilePath(projectInfo.ProjectPath)
    let contentZipFilePath = pathManager.getBackendContentZipFilePath(projectInfo.ProjectPath)
    let zipInternalFilePath = 'awsmobile-cli-project/' + awsmobileJSConstant.BackendProjectYamlFileName
    
    awsMobileYamlOps.writeYamlFileSync(backendProjectSpec, tempContentYmlFilePath)

    let output = fs.createWriteStream(contentZipFilePath)
    
    output.on('close', function() {
      fs.removeSync(tempContentYmlFilePath)
      if(callback){
        callback()
      }
    })

    let zip = archiver.create('zip', {})
    zip.pipe(output)
    zip.append(fs.createReadStream(tempContentYmlFilePath), {name: zipInternalFilePath})
    zip.finalize()
}

archiver

a streaming interface for archive generation

MIT
Latest version published 8 months ago

Package Health Score

89 / 100
Full package analysis