How to use tar-fs - 10 common examples

To help you get started, we’ve selected a few tar-fs 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 exoframejs / exoframe-server / test / deploy.js View on Github external
new Promise(async resolve => {
    // create tar streams
    const streamDocker = tar.pack(path.join(__dirname, 'fixtures', 'docker-project'));
    const streamNode = tar.pack(path.join(__dirname, 'fixtures', 'node-project'));
    const streamHtml = tar.pack(path.join(__dirname, 'fixtures', 'html-project'));
    const streamHtmlUpdate = tar.pack(path.join(__dirname, 'fixtures', 'html-project'));
    const streamCompose = tar.pack(path.join(__dirname, 'fixtures', 'compose-project'));
    const streamComposeUpdate = tar.pack(path.join(__dirname, 'fixtures', 'compose-project'));
    const streamBrokenDocker = tar.pack(path.join(__dirname, 'fixtures', 'broken-docker-project'));
    const streamBrokenNode = tar.pack(path.join(__dirname, 'fixtures', 'broken-node-project'));

    // options base
    const optionsBase = {
      method: 'POST',
      url: '/deploy',
      headers: {
        Authorization: `Bearer ${token}`,
      },
    };
github apigee / apigeetool-node / lib / deploycommon.js View on Github external
pack.on('close', function() {
        try {
          var packageArchive =  path.join(tempDir, packageName);
          fs.createReadStream(packageArchive).pipe(zlib.createGunzip()).pipe(tar.extract(tempDir)).on('finish', function() {
            fs.removeSync(packageArchive) // remove the pack archive so it doesn't show up in the proxy            
            
            if (opts.debug) {
              console.log('bundled dependencies ready for upload')
            }
  
            // return path to packed directory
            return cb(undefined, path.join(tempDir, 'package'))
          }).on('error', function(err) {
            return cb(err);
          });
        } catch(err) {
          return cb(err)
        }
      }); 
    });
github nocproject / noc / ui / web / builder / src / index.js View on Github external
.forEach(value => {
                    const file = value.name.replace(/{hash}/, value.hash);
                    content = content.replace(value.name, file);
                });
                // add hash to theme specific files
                themes.forEach(theme => {
                    const appHash = hash(values,'bundle_app_{hash}', theme);
                    const vendorHash = hash(values, 'bundle_vendor_{hash}', theme);
                    let body;
                    body = template.replace(/{theme}/g, theme);
                    body = body.replace(/{app_hash}/, appHash);
                    themeSpecific.push(body.replace(/{vendor_hash}/, vendorHash));
                });
                content = content.replace(/{theme_specific}/, themeSpecific.join('\n'));
                writeDesktop(content);
                tar.pack(distDir).pipe(zlib.createGzip()).pipe(output);
                console.log('Done');
            },
            error => {
github fulcrumapp / fulcrum-desktop / resources / yarn / yarn / lib / util / git.js View on Github external
process(proc, resolve, reject, done) {
          const extractor = tarFs.extract(dest, {
            dmode: 0o555, // all dirs should be readable
            fmode: 0o444 });

          extractor.on('error', reject);
          extractor.on('finish', done);

          proc.stdout.pipe(extractor);
        }
      });
github yarnpkg / yarn / src / util / git.js View on Github external
process(proc, update, reject, done) {
        const extractor = tarFs.extract(dest, {
          dmode: 0o555, // all dirs should be readable
          fmode: 0o444, // all files should be readable
        });
        extractor.on('error', reject);
        extractor.on('finish', done);

        proc.stdout.pipe(extractor);
        proc.on('error', reject);
      },
    });
github nano-wallet-company / nano-wallet-desktop / ember-electron / assets.js View on Github external
const extractAsset = async (savePath, extractDir, onProgress) => {
  log.info('Extracting asset:', savePath);

  const start = Date.now();
  const extract = tarStream.extract();
  const { size } = await fs.statAsync(savePath);
  const result = await pump(
    // eslint-disable-next-line security/detect-non-literal-fs-filename
    fs.createReadStream(savePath),
    createProgressStream(size, onProgress),
    lzma.createDecompressor(),
    tar.extract(extractDir, {
      fs,
      extract,
      fmode: 0o600,
      dmode: 0o700,
    }),
  );

  const elapsed = Date.now() - start;
  log.info('Asset extracted:', savePath, `(took ${prettyMs(elapsed)})`);
  return result;
};
github zeit / now / packages / now-cli / src / util / dev / builder-cache.ts View on Github external
export async function prepareBuilderDir() {
  const builderDir = join(await cacheDirPromise, 'builders');
  await mkdirp(builderDir);

  // Extract the bundled `builders.tar.gz` file, if necessary
  const bundledTarballPath = join(__dirname, '../../../assets/builders.tar.gz');

  const existingPackageJson =
    (await readFileOrNull(join(builderDir, 'package.json'), 'utf8')) || '{}';
  const { dependencies = {} } = JSON.parse(existingPackageJson);

  if (!hasBundledBuilders(dependencies)) {
    const extractor = extract(builderDir);
    await pipe(
      createReadStream(bundledTarballPath),
      createGunzip(),
      extractor
    );
  }

  return builderDir;
}
github balena-io / balena-preload / lib / preload.js View on Github external
_build () {
    const files = ['Dockerfile', 'requirements.txt', 'src/preload.py']
    const name = 'Building Docker preloader image.'
    this._progress(name, 0)

    const tarStream = tarfs.pack(path.resolve(__dirname, '..'), { entries: files })
    return this.docker.buildImage(tarStream, { t: DOCKER_IMAGE_TAG })
    .then((build) => {
      return new Promise((resolve, reject) => {
        this.docker.modem.followProgress(
          build,
          (error, output) => {  // onFinished
            if (error) {
              reject(error)
            } else {
              this._progress(name, 100)
              resolve()
            }
          },
          (event) => {  // onProgress
            if (event.stream) {
              const matches = event.stream.match(DOCKER_STEP_RE)
github staticland / staticland-api / tests / server.js View on Github external
test('deploy', function (t) {
  var tarstream = tar.pack(path.join(__dirname, 'example-site'))
  var options = { domain: 'hi.com', authorization: `Bearer ${token}` }
  staticland.deploy(tarstream, options, function (err, res, body) {
    t.notOk(err)
    t.ok(res)
    t.ok(body)
    t.end()
  })
})
github testcontainers / testcontainers-node / src / docker-client.ts View on Github external
public async buildImage(repoTag: RepoTag, context: BuildContext, buildArgs: BuildArgs): Promise {
    log.info(`Building image '${repoTag.toString()}' with context '${context}'`);

    const tarStream = tar.pack(context);
    const stream = await this.dockerode.buildImage(tarStream, {
      buildargs: buildArgs,
      t: repoTag.toString()
    });
    await streamToArray(stream);
  }

tar-fs

filesystem bindings for tar-stream

MIT
Latest version published 8 months ago

Package Health Score

79 / 100
Full package analysis

Popular tar-fs functions