• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript archiver.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中archiver.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了default函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: archiveIt

function archiveIt(buildLocation:string, bundlePath:string, callback) {
  let sourceDir = pathResolve(buildLocation, 'bundle');
  bundlePath = bundlePath || pathResolve(buildLocation, 'bundle.tar.gz');
  callback = _.once(callback);

  console.log("Creating tar bundle: " + bundlePath);
  console.log("Bundle source: " + sourceDir);

  var output  = fs.createWriteStream(bundlePath);
  var archive = archiver('tar', {
    gzip: true,
    gzipOptions: {
      level: 6
    }
  });

  archive.pipe(output);
  output.once('close', callback);

  archive.once('error', (err) => {
    console.log("=> Archiving failed:", err.message);
    callback(err);
  });
  archive.directory(sourceDir, 'bundle').finalize();
}
开发者ID:aadamsx,项目名称:typeloy,代码行数:25,代码来源:build.ts


示例2: createZip

export async function createZip(zipPath: string) {
  const output = createWriteStream(zipPath);
  const archive = archiver('zip', {
    zlib: { level: 9 }, // Sets the compression level.
  });

  archive.pipe(output);
  const p = new Promise((resolve, reject) => {
    output.on('end', () => {
      resolve();
    });
    archive.on('error', (err: Error) => {
      reject(err);
    });
  });
  const availablePictures = await getAvailablePictures();

  await Promise.all(
    availablePictures.map(async fileName => {
      archive.append(await fs.readFile(path.resolve(`${picturePath}/${fileName}`)), { name: fileName });
    })
  );
  archive.finalize();

  return p.then(() => fs.readFile(zipPath));
}
开发者ID:marudor,项目名称:randomCats,代码行数:26,代码来源:pictures.ts


示例3: syncReleases

export async function buildInstaller(options: SquirrelOptions, outputDirectory: string, setupExe: string, packager: WinPackager, appOutDir: string) {
  const appUpdate = await packager.getTempFile("Update.exe")
  await BluebirdPromise.all([
    copy(path.join(options.vendorPath, "Update.exe"), appUpdate)
      .then(() => packager.sign(appUpdate)),
    BluebirdPromise.all([remove(`${outputDirectory.replace(/\\/g, "/")}/*-full.nupkg`), remove(path.join(outputDirectory, "RELEASES"))])
      .then(() => ensureDir(outputDirectory))
  ])

  if (options.remoteReleases) {
    await syncReleases(outputDirectory, options)
  }

  const embeddedArchiveFile = await packager.getTempFile("setup.zip")
  const embeddedArchive = archiver("zip", {zlib: {level: options.packageCompressionLevel == null ? 6 : options.packageCompressionLevel}})
  const embeddedArchiveOut = createWriteStream(embeddedArchiveFile)
  const embeddedArchivePromise = new BluebirdPromise(function (resolve, reject) {
    embeddedArchive.on("error", reject)
    embeddedArchiveOut.on("close", resolve)
  })
  embeddedArchive.pipe(embeddedArchiveOut)

  embeddedArchive.file(appUpdate, {name: "Update.exe"})
  embeddedArchive.file(options.loadingGif ? path.resolve(options.loadingGif) : path.join(__dirname, "..", "..", "templates", "install-spinner.gif"), {name: "background.gif"})

  const version = convertVersion(options.version)
  const packageName = `${options.name}-${version}-full.nupkg`
  const nupkgPath = path.join(outputDirectory, packageName)
  const setupPath = path.join(outputDirectory, setupExe || `${options.name || options.productName}Setup.exe`)

  await BluebirdPromise.all<any>([
    pack(options, appOutDir, appUpdate, nupkgPath, version, options.packageCompressionLevel),
    copy(path.join(options.vendorPath, "Setup.exe"), setupPath),
  ])

  embeddedArchive.file(nupkgPath, {name: packageName})

  const releaseEntry = await releasify(options, nupkgPath, outputDirectory, packageName)

  embeddedArchive.append(releaseEntry, {name: "RELEASES"})
  embeddedArchive.finalize()
  await embeddedArchivePromise

  const writeZipToSetup = path.join(options.vendorPath, "WriteZipToSetup.exe")
  await execWine(writeZipToSetup, [setupPath, embeddedArchiveFile])

  await packager.signAndEditResources(setupPath)
  if (options.msi && process.platform === "win32") {
    const outFile = setupExe.replace(".exe", ".msi")
    await msi(options, nupkgPath, setupPath, outputDirectory, outFile)
    // rcedit can only edit .exe resources
    await packager.sign(path.join(outputDirectory, outFile))
  }
}
开发者ID:heinzbeinz,项目名称:electron-builder,代码行数:54,代码来源:squirrelPack.ts


示例4: makeArchive

function makeArchive(app: string, includeDotfiles: boolean) {
  // create a file to stream archive data to.
  const { name: tarPath } = tmp.fileSync({
    discardDescriptor: true,
    prefix: `${app}-deploy-`,
    postfix: '.tar.gz'
  });
  const output = fs.createWriteStream(tarPath);
  const archive = archiver('tar', {
    gzip: true
  });

  // listen for all archive data to be written
  output.on('close', () => {
    // print something?
  });

  // good practice to catch warnings (ie stat failures and other non-blocking errors)
  archive.on('warning', (err) => {
    if (err.code === 'ENOENT') {
      // log warning
    } else {
      // throw error
      throw err;
    }
  });

  // good practice to catch this error explicitly
  archive.on('error', (err) => {
    throw err;
  });

  // pipe archive data to the file
  archive.pipe(output);

  return globby('**', {
    dot: includeDotfiles,
    gitignore: true,
    gitignoreName: '.skyignore'
  })
    .then((paths: [string]) => {
      paths.forEach((path) => {
        archive.file(path, {
          name: path
        });
      });
      // finalize the archive (ie we are done appending files but streams have to finish yet)
      return archive.finalize();
    })
    .then(() => {
      return tarPath;
    });
}
开发者ID:SkygearIO,项目名称:skycli,代码行数:53,代码来源:deploy.ts


示例5: exportAllDataAsZIP

 async exportAllDataAsZIP() {
   const params = await this.paramsP
   const rootPath = params.home;
   const myFS = params.fs;
   const archive = archiver('zip');
   if (await myFS.exists(path.join(rootPath, 'indicators'))) {
     archive.directory(path.join(rootPath, 'indicators'), '/indicators', undefined, { name: 'indicators'});
   }
   const files = ['duniter.db', 'stats.json', 'wotb.bin'];
   for (const file of files) {
     if (await myFS.exists(path.join(rootPath, file))) {
       archive.file(path.join(rootPath, file), { name: file });
     }
   }
   archive.finalize();
   return archive;
 }
开发者ID:Kalmac,项目名称:duniter,代码行数:17,代码来源:server.ts


示例6: archiver

 return new Promise<any>((resolve, reject) => {
   let output  = fs.createWriteStream(bundlePath);
   let archive = archiver('tar', {
     gzip: true,
     gzipOptions: gzipOptions
   });
   archive.pipe(output);
   output.once('close', () => {
     this.emit('archive.finished', { message: "Bundle file is archived.", bundlePath, buildLocation });
     this.emit('finished', { message: "Build finished", bundlePath, buildLocation });
     resolve();
   });
   archive.once('error', (err) => {
     console.log("=> Archiving failed:", err.message);
     this.emit('fail', { message: err.message, error: err, bundlePath, buildLocation });
     reject(err);
   });
   archive.directory(sourceDir, 'bundle').finalize();
 });
开发者ID:c9s,项目名称:typeloy,代码行数:19,代码来源:MeteorBuilder.ts


示例7: invoke

export function invoke(appName: string, appFolder: string, outputPath: string, callback: Function) {
    var archive = archiver('zip');
    var zipFile = p.join(os.tmpdir(), appName + '.zip');
    var output = fs.createWriteStream(zipFile);
    archive.on('error', function (err: any) {
        return callback && callback(err);
    });

    archive.pipe(output);

    archive.directory(appFolder, appName);
    archive.finalize();
    output.on('close', function () {
        var options = {
            method: 'POST',
            url: url.resolve(serviceEndpoint, '/v2/build'),
            encoding: 'binary'
        };
        console.log('Invoking the CloudAppX service...');

        var req = request.post(options, function (err: any, resp: any, body: string) {
            if (err) {
                return callback && callback(err);
            }

            if (resp.statusCode !== 200) {
                return callback && callback(new Error('Failed to create the package. The CloudAppX service returned an error - ' + resp.statusMessage + ' (' + resp.statusCode + '): ' + body));
            }

            fs.writeFile(outputPath, body, { 'encoding': 'binary' }, function (err) {
                if (err) {
                    return callback && callback(err);
                }

                fs.unlink(zipFile, function (err) {
                    return callback && callback(err);
                });
            });
        });

        req.form().append('xml', fs.createReadStream(zipFile));
    });
}
开发者ID:VvanGemert,项目名称:hwa-cli,代码行数:43,代码来源:cloudAppx.ts


示例8: archiver

 client.on("zip", (data) => {
     //exclusively for torrents
     var id = data.id;
     if (torrents[id].zipping || torrents[id].progress < 100) {
         //invalid context
         return false;
     }
     var zippedLength = 0;
     //no need to check if zip exists
     //event will emit only if zipExists is not set
     var output = FILE.createWriteStream(path.join(FILES_PATH, id + ".zip"));
     var archive = archiver('zip', {
         store: true // Sets the compression method to STORE.
     });
     // listen for all archive data to be written
     output.on('close', function () {
         debug("Zipped %s successfully", id);
         torrents[id].zipping = false;
         torrents[id].msg = "Zipped Successfully"
         torrents[id].zipExists = true;
         sendTorrentsUpdate(io, id);
     });
     archive.on('error', function (err) {
         debug("Error while zipping %s : %s", id, err);
     });
     // pipe archive data to the file
     archive.pipe(output);
     archive.directory(path.join(FILES_PATH, id), false);
     archive.finalize();
     var percent = 0;
     //listen for progress
     archive.on("data", (chunk) => {
         zippedLength += chunk.length;
         var percentNow = percentage(zippedLength / torrents[id].length);
         if ((percentNow - percent) > 0.1 || percentNow == 100) {
             percent = percentNow;
             torrents[id].msg = "Zipping : " + percentNow + "%";
             torrents[id].zipping = true;
             sendTorrentsUpdate(io, id);
         }
     });
 });
开发者ID:jazz19972,项目名称:n00b,代码行数:42,代码来源:server.ts


示例9: archiveFolder

export async function archiveFolder(folderPath, targetPath, zipName) {
    var defer = Q.defer();
    tl.debug('Archiving ' + folderPath + ' to ' + zipName);
    var outputZipPath = path.join(targetPath, zipName);
    var output = fs.createWriteStream(outputZipPath);
    var archive = archiver('zip');
    output.on('close', function () {
        tl.debug('Successfully created archive ' + zipName);
        defer.resolve(outputZipPath);
    });

    output.on('error', function(error) {
        defer.reject(error);
    });

    archive.pipe(output);
    archive.directory(folderPath, '/');
    archive.finalize();

    return defer.promise;
}
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:21,代码来源:ziputility.ts


示例10: Buffer

credsPromise.then((creds: ICredentials) => {
    var headers = {
        "User-Agent": "vso-task-api",
        // 2.0 is the single-PUT version
        "Accept": "application/json; api-version=2.0-preview",
        "Authorization": 'Basic ' + new Buffer(creds.username + ':' + creds.password).toString("base64"),
        "X-TFS-FedAuthRedirect": "Suppress",
        "Content-Type": "application/octet-stream"
    };

    var archive = archiver('zip');
    archive.directory(taskFolder, false);

    _sendFile("PUT", taskUrl, archive, headers,(err: any, res: any, contents: any) => {
        console.log(res);
        console.log(contents);
        if (err) {
            console.error(err);
        }
    });
    
    archive.finalize();
}).fail((reason) => {
开发者ID:AnubhavAggarwal,项目名称:vso-agent-tasks,代码行数:23,代码来源:taskUploader.ts



注:本文中的archiver.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript argparse.ArgumentParser类代码示例发布时间:2022-05-25
下一篇:
TypeScript archiver.create函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap