How to use extract-zip - 9 common examples

To help you get started, we’ve selected a few extract-zip 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 electron / fiddle / tests / renderer / binary-spec.ts View on Github external
it('handles an error in the zip file', async () => {
      const eDownload = require('electron-download');
      eDownload.mockImplementationOnce((_p: any, c: any) => c(undefined, '/fake/path'));

      const mockZip = require('extract-zip');
      mockZip.mockImplementationOnce((_a: any, _b: any, c: any) => c(new Error('bwap-bwap')));

      await binaryManager.setup('v3.0.0');
    });
  });
github machawk1 / wail / tools / downloadExternals.js View on Github external
return new Promise((resolve, reject) => {
    let name = path.basename(zipPath).replace(zipRE, '')
    extract(zipPath, { dir: `${zips}` }, zipError => {
      if (zipError) {
        console.error(zipError)
        reject(zipError)
      } else {
        console.log(`done extracting ${name} ensuring content is not read only`)
        console.log(`done ensuring not read only for ${name}`)
        resolve()
      }
    })
  })
}
github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / installResolver / utils / downloadInstallationFiles.js View on Github external
return new Promise((resolve, reject) => {
        extract(zipPath, { dir }, e => {
            if (e) {
                reject(e);
                return;
            }
            resolve();
        });
    });
}
github rocjs / roc / src / commands / init / fetchTemplate.js View on Github external
return new Promise((resolve) => {
        extract(template, { dir: tmp }, (error) => {
            if (error) {
                log.error(`Failed to extract template from "${template}"`, error);
            }
            const files = fs.readdirSync(tmp);
            if (files.length !== 1) {
                log.error(`The template seems no to be structured correctly "${template}"`);
            }

            resolve(path.join(tmp, files[0]));
        });
    });
}
github stream-labs / streamlabs-obs / app / services / scene-collections / overlays.ts View on Github external
await new Promise((resolve, reject) => {
      extractZip(overlayFilePath, { dir: assetsPath }, err => {
        if (err) {
          reject(err);
        } else {
          resolve();
        }
      });
    });
github webiny / webiny-js / packages / api-page-builder / src / plugins / graphql / installResolver / installPageElements.js View on Github external
return new Promise((resolve, reject) => {
        extract(zipPath, { dir }, e => {
            if (e) {
                reject(e);
                return;
            }
            resolve();
        });
    });
}
github miscord / miscord / src / bin / buildMacApp.ts View on Github external
const extract = (path: string, opts: extractZip.Options) => new Promise((resolve, reject) => extractZip(path, opts, err => { if (err) reject(err); else resolve() }))
github valentjn / vscode-ltex / src / Dependencies.ts View on Github external
const archiveName: string = Path.basename(url.pathname);
    const archiveType: string = ((Path.extname(archiveName) == '.zip') ? 'zip' : 'tar.gz');
    const tmpDirPath: string = Fs.mkdtempSync(Path.join(this._context.extensionPath, 'tmp-'));
    const archivePath: string = Path.join(tmpDirPath, archiveName);
    codeProgress.finishTask();

    codeProgress.startTask(0.8, i18n('downloading', name));
    Logger.log(i18n('downloadingFromTo', name, urlStr, archivePath));
    await Dependencies.downloadFile(urlStr, archivePath, codeProgress);
    codeProgress.finishTask();

    codeProgress.startTask(0.1, i18n('extracting', name));
    Logger.log(i18n('extractingTo', archivePath, tmpDirPath));

    if (archiveType == 'zip') {
      await extractZip(archivePath, {dir: tmpDirPath});
    } else {
      await Tar.extract({file: archivePath, cwd: tmpDirPath});
    }

    codeProgress.updateTask(0.8);

    const fileNames: string[] = Fs.readdirSync(tmpDirPath);
    let extractedDirPath: string | null = null;
    Logger.log(i18n('searchingForDirectory', tmpDirPath));

    for (let i: number = 0; i < fileNames.length; i++) {
      const filePath: string = Path.join(tmpDirPath, fileNames[i]);
      const stats: Fs.Stats = Fs.lstatSync(filePath);

      if (stats.isDirectory()) {
        if (extractedDirPath == null) {

extract-zip

unzip a zip file into a directory using 100% javascript

BSD-2-Clause
Latest version published 4 years ago

Package Health Score

77 / 100
Full package analysis

Popular extract-zip functions