How to use the tar.c 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 deltachat / deltachat-node / scripts / prebuildify.js View on Github external
function bundle () {
  // FIXME. Temporary fix so Jenkins which is faster can upload
  // binaries. Travis uses deploy functionality in .travis.yml and
  // not using the ghreleases module (which seems to fail if there
  // are already binaries uploaded)
  if (process.env.TRAVIS === 'true') return

  const prebuilds = `${process.platform}-${process.arch}`
  const file = `v${pkg.version}-${process.platform}-${process.arch}.tar.gz`
  const cwd = path.join(process.cwd(), 'prebuilds')
  tar.c({ file, cwd, gzip: true }, [ prebuilds ], err => {
    if (err) exit(err)
    uploadToRelease(path.resolve(__dirname, '..', file))
  })
}
github ArthurClemens / polythene / packages / polythene-scripts / src / write-css.js View on Github external
.then(result => {
      result.warnings().forEach(warn => {
        console.warn(COLOR_RED, "Warning", COLOR_WHITE, warn.toString()); // eslint-disable-line no-console
      });
      saveToFile(path, beautify ? beautifyCSS(result.css) : result.css);
      if (gzip) {
        tar.c(
          { gzip: true },
          [path]
        ).pipe(fs.createWriteStream(`${path}.gz`));
      }
      if (sourceMap) {
        saveToFile(mapPath, result.map);
      }
    });
};
github pulumi / actions-pulumify / infra / bucketDirectory.ts View on Github external
private createTempArchive(): aws.s3.BucketObject {
        // Upload the target directory a single object at a time. This allows us to minimize
        // copying over the Internet, and then to apply an efficient "S3 sync" from within the
        // Amazon data center, where bandwidth to the target S3 bucket will be maximized.
        const arch = tmp.fileSync({ postfix: ".tgz" }).name;

        // Tar up the contents, making sure to set the portable flag so we only detect changes
        // when the actual hash of the contents changes (and not non-portable timestamps, etc).
        tar.c({
            gzip: true,
            sync: true,
            file: arch,
            C: this.source,
            portable: true,
        }, fs.readdirSync(this.source));

        // TODO(joe): when archive can be an asset, we can just use this line, instead of manual tgzing:
        // const arch = new pulumi.asset.FileArchive(args.source);

        // Now create a single object in the target bucket to hold the resulting archive and return it.
        return new aws.s3.BucketObject(`${this.name}-archive`, {
            key: "__aws.s3.BucketDirectory.archive.tar.gz",
            bucket: this.bucket,
            source: new pulumi.asset.FileAsset(arch),
        }, { parent: this });
github arturock / basecamp-linux / scripts / build.js View on Github external
compress(appPath) {
    const basePath = path.dirname(appPath);
    const appDir = path.basename(appPath);
    const name = path.basename(appPath).replace(APP_NAME, `${APP_NAME}-${APP_VERSION}`);
    const filename = `${name}.tar.xz`;
    cp.execSync(`mkdir -p ${DIST_PATH}`, { stdio: 'inherit' });

    console.log(`\nGenerating ${filename}...`);

    tar
      .c({ sync: true, cwd: basePath }, [appDir])
      .pipe(lzma.createCompressor())
      .pipe(fs.createWriteStream(path.join(DIST_PATH, filename)))
      .on('finish', () => {
        console.log(` ${filename} ready`);
      });
  },
github npm / pacote / lib / dir.js View on Github external
      .then(files => tar.c(this[_tarcOpts](), files)
        .on('error', er => stream.emit('error', er)).pipe(stream))
      .catch(er => stream.emit('error', er))
github CircuitCoder / Console-Lite / main.js View on Github external
function createExportStream() {
  if(serverStarted) throw new Error('Server is running');
  const dir = serverUtil.storagePath();

  return tar.c({
    C: dir,
    prefix: 'storage',
  }, fs.readdirSync(dir));
}
github wordup-dev / wordup-cli / src / commands / cloud / publish.js View on Github external
fs.statSync(sourceDirectory);
    } catch (err) {
        if (err.code === "ENOENT") {
          this.error('Project directory is not readable')
          return false;
        }
    }

    await this.getAccessToken()
    if(!this.accessToken){
        return false
    }
    //Get all files which are not ignored
    const allFiles = await this.listFiles(sourceDirectory);

    const archiveResult = await tar.c({
        gzip: true,
        file: tmpFile.name,
        cwd: sourceDirectory,
        follow: true,
        noDirRecurse: true,
        portable: true,
    },allFiles).then(() => {
        const stats = fs.statSync(tmpFile.name);
        return {
            file: tmpFile.name,
            manifest: allFiles,
            size: stats.size,
            source: sourceDirectory,
        };
    });
github leanix / leanix-reporting-cli / src / uploader.ts View on Github external
private createTarFromSrcFolderAndAddToDist() {
    const files = fs.readdirSync(path.resolve(this.projectDir, 'src'));
    return tar.c({ gzip: true, cwd: 'src', file: 'dist/src.tgz' }, files);
  }