How to use the tar.x function in tar

To help you get started, we’ve selected a few tar 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 huan / node-facenet / src / dataset / lfw.ts View on Github external
public async extract(): Promise {
    log.verbose('Lfw', 'extract()')

    const EXTRACTED_MARK_FILE = path.join(this.directory, 'EXTRACTED')
    if (fs.existsSync(EXTRACTED_MARK_FILE)) {
      log.silly('Lfw', 'extract() already extracted')
      return
    }

    await tar.x({
      file:   this.downloadFile,
      strip:  1,
      cwd:    this.directory,
    })

    fs.closeSync(fs.openSync(EXTRACTED_MARK_FILE, 'w')) // touch the file
  }
github uber / baseweb / scripts / build-docs.js View on Github external
for (let version in latestMajors) {
    const filePath = path.resolve(__dirname, '../public', `${version}.tar`);
    const directoryTmp = path.resolve(__dirname, '../public', `${version}-tmp`);
    const directory = path.resolve(__dirname, '../public', `${version}`);

    mkdirp.sync(directoryTmp);
    mkdirp.sync(directory);

    await downloadFile({
      latestMajors,
      version,
      filePath,
    });

    tar.x({
      file: filePath,
      cwd: directoryTmp,
      sync: true,
      strip: 1,
    });

    // eventstream 3 has a security issue and was removed from the registry
    if (Number(version.replace('v', '')) < 5) {
      patchEventstream(path.resolve(directoryTmp, 'package.json'));
    }

    childProcess.execSync('yarn install', {
      cwd: directoryTmp,
    });

    childProcess.execSync(majors[version].buildCommand, {
github tensorflow / tfjs-node / tfjs-node / scripts / resources.js View on Github external
response.on('data', chunk => bar.tick(chunk.length))
          .pipe(outputFile)
          .on('close', async () => {
            const zipFile = new zip(tempFileName);
            zipFile.extractAllTo(destPath, true /* overwrite */);

            await unlink(tempFileName);

            if (callback !== undefined) {
              callback();
            }
          });
    } else if (uri.endsWith('.tar.gz')) {
      response.on('data', chunk => bar.tick(chunk.length))
          .pipe(tar.x({C: destPath, strict: true}))
          .on('close', () => {
            if (callback !== undefined) {
              callback();
            }
          });
    } else {
      throw new Error(`Unsupported packed resource: ${uri}`);
    }
  });
  request.end();
github jnsmalm / gameplay / build.ts View on Github external
extract(filename: string, dest: string) {
    console.log(`extract ${filename}...`)
    return tar.x({
      file: filename,
      C: dest
    })
  }
github eclipse-theia / theia / packages / java / scripts / shared.js View on Github external
return new Promise((resolve, reject) => {
        if (!fs.existsSync(archivePath)) {
            reject(new Error(`The archive was not found at ${archivePath}.`));
            return;
        }
        if (!fs.existsSync(targetPath)) {
            mkdirp.sync(targetPath);
        }
        const gunzip = zlib.createGunzip({ finishFlush: zlib.Z_SYNC_FLUSH, flush: zlib.Z_SYNC_FLUSH });
        console.log(`Decompressing the archive to ${targetPath}.`);
        const untar = tar.x({ cwd: targetPath });
        fs.createReadStream(archivePath).pipe(gunzip).pipe(untar)
            .on('error', e => reject(e))
            .on('end', () => resolve());
    });
}
github garden-io / garden / garden-service / src / util / ext-tools.ts View on Github external
sha256,
            })
          )
        }
      })

      if (!this.spec.extract) {
        const targetExecutable = join(tmpPath, ...this.targetSubpath)
        response.data.pipe(createWriteStream(targetExecutable))
        response.data.on("end", () => resolve())
      } else {
        const format = this.spec.extract.format
        let extractor: Writable

        if (format === "tar") {
          extractor = tar.x({
            C: tmpPath,
            strict: true,
          })
          extractor.on("end", () => resolve())
        } else if (format === "zip") {
          extractor = Extract({ path: tmpPath })
          extractor.on("close", () => resolve())
        } else {
          reject(
            new ParameterError(`Invalid archive format: ${format}`, {
              name: this.name,
              spec: this.spec,
            })
          )
          return
        }
github signalapp / Signal-Desktop / js / modules / backup.js View on Github external
async function decompressArchive(file, targetDir) {
  return tar.x({
    file,
    cwd: targetDir,
  });
}
github pavjacko / renative / packages / rnv / src / systemTools / crypto.js View on Github external
.then(() => {
                tar.x(
                    {
                        file: destTemp,
                        cwd: c.paths.workspace.dir
                    }
                ).then(() => {
                    removeFilesSync([destTemp]);
                    if (fs.existsSync(ts)) {
                        copyFileSync(ts, path.join(c.paths.workspace.dir, c.files.project.package.name, 'timestamp'));
                    }
                    logSuccess(`Files succesfully extracted into ${c.paths.workspace.dir}`);
                    resolve();
                })
                    .catch(e => reject(e));
            }).catch((e) => {
                reject(e);
github avh4 / binwrap / binstall.js View on Github external
return new Promise(function(resolve, reject) {
    var untar = tar
      .x({ cwd: path })
      .on("error", function(error) {
        reject("Error extracting " + url + " - " + error);
      })
      .on("end", function() {
        var successMessage = "Successfully downloaded and processed " + url;

        if (verify) {
          verifyContents(verify)
            .then(function() {
              resolve(successMessage);
            })
            .catch(reject);
        } else {
          resolve(successMessage);
        }
github embark-framework / embark / packages / embark / src / lib / utils / utils.js View on Github external
function extractTar(filename, packageDirectory, cb) {
  const o_fs = require('fs-extra');
  const tar = require('tar');
  o_fs.createReadStream(filename).pipe(
    tar.x({
      strip: 1,
      C: packageDirectory
    }).on('end', function () {
      cb();
    })
  );
}