How to use the tar.create 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 imodeljs / imodeljs / tools / webpack / bin / buildIModelJsModule.js View on Github external
// prepare the digital signature operation
        if (signer) {
            if (this._detail > 3)
                console.log("Calculating signature of plugin resources");
            const signatureFile = path.resolve(buildDir, SIGNATURE_FILENAME);
            const signResult = signer.createSignatureFile(buildDir, fileList, signatureFile);
            if (signResult instanceof Result)
                return Promise.resolve(signResult);
            fileList.push(SIGNATURE_FILENAME);
        }
        if (this._detail > 3)
            console.log("Creating tar file for plugin", subModule.bundleName);
        Utils.makeDirectoryNoError(tarDirectory);
        const tarFile = path.resolve(tarDirectory, subModule.bundleName.concat(".plugin.tar"));
        try {
            await tar.create({ cwd: buildDir, gzip: false, file: tarFile, follow: true }, fileList);
        }
        catch (error) {
            return Promise.resolve(new Result(`Build Plugin ${subModule.bundleName}`, 1, error, "Creating tar file"));
        }
        /* ----------- This is relevant only for the BrowserLocalPluginLoader, which is not currently used.
        // for debugging, put the development version 'bundleName'.js and 'bundlename'.js.map into the same directory as the tar file, and we will preferentially load that.
        const devVersionSource = path.resolve(devCompileOutput, manifest.devPlugin);
        const devVersionDest = path.resolve(outputPath, manifest.devPlugin);
        Utils.symlinkOrCopyModuleFile(devVersionSource, devVersionDest, this._alwaysCopy, this._detail);
           ----------- */
        if (signer) {
            if (this._detail > 3)
                console.log("Verifying signature of plugin tar file");
            // create an output directory, into which we will untar the tar file we just created.
            const verifyResult = await signer.verifySignature(tarFile, subModule, this._detail);
            if (verifyResult)
github expo / expo-cli / packages / xdl / src / Diagnostics.js View on Github external
// remove access token
  try {
    let settingsJsonFile = new JsonFile(path.join(tempDir, UserSettings.SETTINGS_FILE_NAME));
    let settingsJson = await settingsJsonFile.readAsync();
    for (let key of ['accessToken', 'auth', 'uuid', 'sendTo']) {
      if (settingsJson[key]) {
        settingsJson[key] = 'redacted';
      }
    }
    await settingsJsonFile.writeAsync(settingsJson);
  } catch (e) {
    console.error(e);
  }

  // compress
  await tar.create({ file: archivePath, gzip: true, cwd: Env.home() }, [
    path.relative(Env.home(), tempDir),
  ]);
  rimraf.sync(tempDir);

  // upload
  let formData = new FormData();
  formData.append('archive', fs.createReadStream(archivePath));

  let response = await Api.callMethodAsync('uploadDiagnostics', [{}], 'put', null, { formData });
  return response.url;
}
github imodeljs / imodeljs / tools / webpack / modules / buildIModelJsModule.ts View on Github external
console.log("Calculating signature of plugin resources");
      const signatureFile = path.resolve(buildDir, SIGNATURE_FILENAME);
      const signResult: Result | undefined = signer.createSignatureFile(buildDir, fileList, signatureFile);

      if (signResult instanceof Result)
        return Promise.resolve(signResult);

      fileList.push(SIGNATURE_FILENAME);
    }

    if (this._detail > 3)
      console.log("Creating tar file for plugin", subModule.bundleName);
    Utils.makeDirectoryNoError(tarDirectory);
    const tarFile = path.resolve(tarDirectory, subModule.bundleName.concat(".plugin.tar"));
    try {
      await tar.create({ cwd: buildDir, gzip: false, file: tarFile, follow: true }, fileList);
    } catch (error) {
      return Promise.resolve(new Result(`Build Plugin ${subModule.bundleName}`, 1, error, "Creating tar file"));
    }

    /* ----------- This is relevant only for the BrowserLocalPluginLoader, which is not currently used.
    // for debugging, put the development version 'bundleName'.js and 'bundlename'.js.map into the same directory as the tar file, and we will preferentially load that.
    const devVersionSource = path.resolve(devCompileOutput, manifest.devPlugin);
    const devVersionDest = path.resolve(outputPath, manifest.devPlugin);
    Utils.symlinkOrCopyModuleFile(devVersionSource, devVersionDest, this._alwaysCopy, this._detail);
       ----------- */

    if (signer) {
      if (this._detail > 3)
        console.log("Verifying signature of plugin tar file");

      // create an output directory, into which we will untar the tar file we just created.
github sk770 / npm-offline-packager / lib / npm-publish.js View on Github external
const newFileName = fileName.replace('.tgz', '-temp.tgz');
    const newCommand = command.replace(filePath, newFileName);

    // Create directory to extract package
    await mkdirPromise(folderPath).catch(() => {});

    // Extract package
    await extract({ file: filePath, cwd: folderPath });

    // Override publishConfig.registry in package.json
    let packageJson = await readFilePromise(`${folderPath}/package/package.json`, { encoding: 'utf-8' });
    packageJson = packageJson.replace('"publishConfig"', '"publishConfigRemoved"');
    await writeFilePromise(`${folderPath}/package/package.json`, packageJson, { encoding: 'utf-8' });

    // Create new tarball
    await create({ file: newFileName, cwd: folderPath, gzip: true }, ['package']);

    // Run npm publish with new command
    return shellExec(newCommand)
        .then((stdout) => {
            rimraf(folderPath, () => { });
            rimraf(newFileName, () => { });

            return stdout;
        })
        .catch((stderr) => {
            rimraf(folderPath, () => { });

            return Promise.reject(stderr);
        });
}
github ruslang02 / atomos / apps / files / index.html View on Github external
ipcRenderer.once("save-file", function (e, arg) {
					const tar = require('tar');
					tar.create({
						gzip: true,
						file: arg,
						C: file
					}, fs.readdirSync(file))
						.then(function () {
							new Notification({
								title: "Archive was successfully created",
								html: "Find it in your directory listing."
							})
						}).catch(console.error)

				})
			}
github alexieyizhe / alexxie.ca / node_modules / fsevents / node_modules / node-pre-gyp / lib / package.js View on Github external
packlist({ path: from }).then(function(files) {
                var base = path.basename(from);
                files = files.map(function(file) {
                    return path.join(base, file);
                });
                tar.create({
                    portable: true,
                    gzip: true,
                    onentry: filter_func,
                    file: tarball,
                    cwd: path.dirname(from)
                }, files, function(err) {
                    if (err)  console.error('['+package_json.name+'] ' + err.message);
                    else log.info('package','Binary staged at "' + tarball + '"');
                    return callback(err);
                });
            }, callback);
        });
github staltz / react-native-node / bin.js View on Github external
function bundle(originalWorkingDir, sourcePath) {
  const absoluteSourcePath = path.resolve(originalWorkingDir, sourcePath);
  console.log("Bundling the directory " + absoluteSourcePath + " ...");
  process.chdir(absoluteSourcePath);
  const bundleFileList = fs.readdirSync(absoluteSourcePath);
  const targetAbsolutePath = path.resolve(originalWorkingDir, BUNDLE_TAR);
  tar.create(
    { gzip: false, file: targetAbsolutePath, sync: true, portable: true },
    bundleFileList
  );
  process.chdir(originalWorkingDir);
  console.log("\tdone.");
}
github pursuit-gg / pursuit-client / public / uploadCaptureFolderBW.html View on Github external
if (uploadTries < 5) {
            setTimeout(uploadFolder, 3000);
          } else {
            deleteFolder();
          }
          return;
        } else if (!exists) {
          ipc.send('capture-folder-upload-finished', folder, userId, spectator);
          window.close();
          return;
        }
        const folderName = folder.match(/[\\/]([^\\/]+)$/)[1];
        const uploadKey = `fortnite/packed/${userId}/${folderName}.tar.gz`;
        console.log('pre zip');
        const passThrough = new PassThrough();
        tar.create({ gzip: true }, [folder]).pipe(passThrough);
        console.log('post zip');
        const bufs = [];
        passThrough.on('data', data => bufs.push(data));
        passThrough.on('end', () => {
          console.log('get credentials');
          AWS.config.credentials.get((credErr) => {
            if (credErr) {
              console.error(credErr);
              Sentry.captureException(credErr);
              ipc.send('capture-folder-upload-error', folder, userId, spectator, credErr);
              if (uploadTries < 40) {
                setTimeout(uploadFolder, 3000);
              } else {
                deleteFolder();
              }
              return;
github voorhoede / plek / packages / cli / src / fly.js View on Github external
const configPath = fs.existsSync(path.resolve('.fly', '.fly.yml'))
    ? '.fly/.fly.yml'
    : '.fly.yml';

  const entries = [
    configPath,
    ...glob.sync('.fly/*/**.{js,json}', { cwd: process.cwd() }),
    ...yaml
      .safeLoad(fs.readFileSync(path.join(process.cwd(), '.fly.yml')))
      .files.reduce(
        (files, file) => files.push(...glob.sync(file)) && files,
        []
      ),
  ].filter(file => fs.existsSync(path.resolve(process.cwd(), file)));

  return tar.create(
    { portable: true, follow: true, file: '.fly/bundle.tar' },
    entries
  );
};
github graalvm / graaljs / deps / npm / lib / pack.js View on Github external
        .then((files) => tar.create(tarOpt, files.map((f) => `./${f}`)))
        .then(() => getContents(pkg, tmpTarget, filename, logIt))