How to use decompress - 10 common examples

To help you get started, we’ve selected a few decompress 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 nodkz / mongodb-memory-server / packages / mongodb-memory-server-core / src / util / MongoBinaryDownload.ts View on Github external
this.debug(`extract(): ${extractDir}`);

    if (!fs.existsSync(extractDir)) {
      fs.mkdirSync(extractDir);
    }

    let filter;
    if (this.platform === 'win32') {
      filter = (file: any) => {
        return /bin\/mongod.exe$/.test(file.path) || /.dll$/.test(file.path);
      };
    } else {
      filter = (file: any) => /bin\/mongod$/.test(file.path);
    }

    await decompress(mongoDBArchive, extractDir, {
      // extract only `bin/mongod` file
      filter,
      // extract to root folder
      map: (file) => {
        file.path = path.basename(file.path);
        return file;
      },
    });

    if (!(await this.locationExists(path.resolve(this.downloadDir, this.version, binaryName)))) {
      throw new Error(
        `MongoBinaryDownload: missing mongod binary in ${mongoDBArchive} (downloaded from ${this
          ._downloadingUrl ?? 'unkown'}). Broken archive from MongoDB Provider?`
      );
    }
    return extractDir;
github repetere / periodicjs / __LEGACY / app / controller / theme.js View on Github external
var move_upload = function (options) {
	// console.log('options',options);
	var logfile = options.logfile,
		themename = options.themename;
	// fs.rename(returnFile.path,newfilepath,function(err){
	// });
	var decompress = new Decompress()
		.src(options.uploadedfile.path)
		.dest(options.themedir)
		.use(Decompress.zip());
	decompress.decompress(function (err
		//, files
	) {
		if (err) {
			install_logErrorOutput({
				logfile: logfile,
				logdata: err.message
			});
		}
		else {
			install_logOutput({
				logfile: logfile,
				logdata: 'unzipped directory'
			});
			fs.remove(options.uploadedfile.path, function (err
				//, filedir
github codingfriend1 / meanbase / server / api / extensions / extensions.controller.js View on Github external
if(!createdFolderName || !/^[a-zA-Z0-9_-]+$/.test(createdFolderName)) {
        return res.status(501).send('Extension folder name was invalid: "' + createdFolderName + '". It should only contain letters, numbers, and - or _');
      }

      var compressType;
      var decompress = new Decompress();
      switch(contentType) {
        case 'application/x-gzip':
          compressType = Decompress.targz;
          break;
        case 'application/zip':
          compressType = Decompress.zip;
          break;
        case 'application/x-tar':
          compressType = Decompress.tar;
          break;
        case 'application/x-bzip2':
          compressType = Decompress.tar;
          break;
        default:
          compressType = null;
      }

      if(!compressType) {
        return res.status(501).send('Please send a zip, gz, bz2, or tar file type.');
      }

      try {
        // Query the entry
        var stats = fs.lstatSync(createdFolderPath);
        // Is it a directory?
github codingfriend1 / meanbase / server / api / extension / extension.controller.js View on Github external
if(!createdFolderName || !/^[a-zA-Z0-9_-]+$/.test(createdFolderName)) {
        return res.status(501).send('Extension folder name was invalid: "' + createdFolderName + '". It should only contain letters, numbers, and - or _');
      }

      var compressType;
      var decompress = new Decompress();
      switch(contentType) {
        case 'application/x-gzip':
          compressType = Decompress.targz;
          break;
        case 'application/zip':
          compressType = Decompress.zip;
          break;
        case 'application/x-tar':
          compressType = Decompress.tar;
          break;
        case 'application/x-bzip2':
          compressType = Decompress.tar;
          break;
        default:
          compressType = null;
      }

      if(!compressType) {
        return res.status(501).send('Please send a zip, gz, bz2, or tar file type.');
      }

      try {
        // Query the entry
        var stats = fs.lstatSync(app.get('appPath') + 'extensions/' + createdFolderName);
        // Is it a directory?
github codingfriend1 / meanbase / src / services / theme-uploads / unzip.js View on Github external
createdFolderPath = path.join(req.app.get('themesPath'), createdFolderName);

      var compressType;
      var decompress = new Decompress();
      switch(contentType) {
        case 'application/x-gzip':
          compressType = Decompress.targz;
          break;
        case 'application/zip':
          compressType = Decompress.zip;
          break;
        case 'application/x-tar':
          compressType = Decompress.tar;
          break;
        case 'application/x-bzip2':
          compressType = Decompress.tar;
          break;
        default:
          compressType = null;
      }

      if(!compressType) {
        return next(new feathersErrors.NotAcceptable('Please send a zip, gz, bz2, or tar file type.'));
      }

      try {
        // Query the entry
        var stats = fs.lstatSync(createdFolderPath);
        // Is it a directory?
        if (stats.isDirectory()) {
          console.log('already exists');
          return next(new feathersErrors.NotAcceptable('A theme with that name has already been uploaded. Please choose a different folder name for your theme.'));
github sirensolutions / sentinl / server / lib / phantom.js View on Github external
.catch(() => {
    // not exists, install package
    return decompress(`${phantomPackage.dir}/${phantomPackage.base}`, phantomPackage.dir)
    .then(() => changePermissions(phantomPackage, '755'))
    .catch((err) => Promise.reject(err));
  });
};
github codingfriend1 / meanbase / server / api / themes / themes.controller.js View on Github external
createdFolderPath = path.join(app.get('appPath'), 'themes', createdFolderName);

      var compressType;
      var decompress = new Decompress();
      switch(contentType) {
        case 'application/x-gzip':
          compressType = Decompress.targz;
          break;
        case 'application/zip':
          compressType = Decompress.zip;
          break;
        case 'application/x-tar':
          compressType = Decompress.tar;
          break;
        case 'application/x-bzip2':
          compressType = Decompress.tar;
          break;
        default:
          compressType = null;
      }

      if(!compressType) {
        return res.status(501).send('Please send a zip, gz, bz2, or tar file type.');
      }

      try {
        // Query the entry
        var stats = fs.lstatSync(createdFolderPath);
        // Is it a directory?
        if (stats.isDirectory()) {
          return res.status(501).send('A theme with that name has already been uploaded. Please choose a different folder name for your theme.');
        }
github codingfriend1 / meanbase / src / services / extension-uploads / unzip.js View on Github external
return next(new feathersErrors.NotAcceptable('Extension folder name was invalid: "' + createdFolderName + '". It should only contain letters, numbers, and - or _'));
      }

      createdFolderPath = path.join(req.app.get('extensionsPath'), createdFolderName);

      var compressType;
      var decompress = new Decompress();
      switch(contentType) {
        case 'application/x-gzip':
          compressType = Decompress.targz;
          break;
        case 'application/zip':
          compressType = Decompress.zip;
          break;
        case 'application/x-tar':
          compressType = Decompress.tar;
          break;
        case 'application/x-bzip2':
          compressType = Decompress.tar;
          break;
        default:
          compressType = null;
      }

      if(!compressType) {
        return next(new feathersErrors.NotAcceptable('Please send a zip, gz, bz2, or tar file type.'));
      }

      try {
        // Query the entry
        var stats = fs.lstatSync(createdFolderPath);
        // Is it a directory?
github bchr02 / instantclient / instantclient.js View on Github external
.on('close', function() {
		new Decompress()
			.src(fullPathToFile)
			.dest(dir)
			.use(Decompress.zip({strip: 1}))
			.run(function(error) {
				if(error) {
					console.error(error);
					return;
				}
				console.log(fn + " extracted");
				fs.unlink(fullPathToFile, function(error) {
					if(error) {
						console.error(error);
						return;
					}
					console.log(fn + " deleted");
				});
			});
	});
};
github serverless / emulator / src / utils / unzipFunctionCode.js View on Github external
async function unzipFunctionCode(zipFilePath, functionId) {
  const functionCodeDirectoryPath = getFunctionCodeDirectoryPath(functionId);
  return decompress(zipFilePath, functionCodeDirectoryPath);
}

decompress

Extracting archives made easy

MIT
Latest version published 4 years ago

Package Health Score

65 / 100
Full package analysis