當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript archiver.default方法代碼示例

本文整理匯總了TypeScript中archiver.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript archiver.default方法的具體用法?TypeScript archiver.default怎麽用?TypeScript archiver.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在archiver的用法示例。


在下文中一共展示了archiver.default方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: createZip

// Create a zip file of the fixture data using the given zlib compression level.
function createZip(level: number): void {
  const output = fs.createWriteStream(`${outputFolder}/zipfs_fixtures_l${level}.zip`);
  const options = { zlib: { level: level } };
  const archive = archiver('zip', options);
  archive.on('error', (err: any) => {
    throw err;
  });
  archive.pipe(output);
  addFolder(archive, srcFolder);
  archive.finalize();
}
開發者ID:diegolameira,項目名稱:codesandbox-client,代碼行數:12,代碼來源:make_zip_fixtures.ts

示例2: send_zip

function send_zip(path: string, name: string, res: express.Response){
	res.setHeader('Content-disposition', 'attachment; filename='+name+'.zip');
	res.setHeader('Content-type', 'application/zip');
	let archive = archiver('zip');
	archive.on('error', (e: Error) => {
		socket_manager.broadcast('report-error', e);
		res.end();
	});
	archive.pipe(res);
	archive.directory(path, name, {name: name+'.zip'});
	archive.finalize();
}
開發者ID:BelaPlatform,項目名稱:Bela,代碼行數:12,代碼來源:RouteManager.ts

示例3: Promise

 return new Promise((resolve, reject) => {
   this.out.action.start(`Zipping export`)
   const before = Date.now()
   const archive = archiver('zip')
   archive.directory(this.exportDir, false)
   const output = fs.createWriteStream(this.exportPath)
   archive.pipe(output)
   output.on('close', () => {
     console.log(archive.pointer() + ' total bytes')
     this.out.action.stop(chalk.cyan(`${Date.now() - before}ms`))
     resolve()
   })
   archive.finalize()
 })
開發者ID:ahmb84,項目名稱:prisma,代碼行數:14,代碼來源:Exporter.ts

示例4: archiver

 let finalBuffer = await new Promise<Buffer>((resolve, reject) => {
     let archive = archiver('zip');
     archive.on('warning', function (err: any) {
         if (err.code === 'ENOENT') {
             console.log(err);
         } else {
             // throw error
             reject(err);
         }
     });
     archive.on('data', data => buffers.push(data));
     archive.on('error', reject);
     archive.on('end', () => resolve(Buffer.concat(buffers)));
     filesToAdd.forEach(elem => archive.append(elem.content, { name: elem.path }));
     archive.finalize();
 });
開發者ID:gregg-miskelly,項目名稱:omnisharp-vscode,代碼行數:16,代碼來源:TestZip.ts

示例5: asyncUploadWorkspaceDump

    private asyncUploadWorkspaceDump(url: string) {
        const storagePath = this.ctx.extensionContext.storagePath
        // TODO: handle multi-root workspaces
        const rootPath = vscode.workspace.rootPath
        if (storagePath === undefined || rootPath === undefined) {
            this.logError('Cannot start workspace dump b/c of workspace state:', { storagePath, rootPath })
            return
        }

        if (!fs.existsSync(storagePath)) fs.mkdirSync(storagePath)
        const outputPath = path.join(storagePath, 'workspace-dump.zip')
        if (fs.existsSync(outputPath)) fs.unlinkSync(outputPath)
        const output = fs.createWriteStream(outputPath)

        const zip = archiver('zip')
        zip.on('error', (err) => this.logError('zip error', safeError(err)))
        zip.on('warning', (err) => this.logError('zip warning', safeError(err)))
        zip.on('finish', () => {
            this.ctx.extensionOut.appendLine('zip - finished')
            fs.createReadStream(outputPath).pipe(
                request.put(url, {
                    qs: {
                        client: this.machineId,
                        project: this.projectId,
                        session: this.sessionId
                    }
                })
                    .on('error', (err) => this.logError('zip upload connection error', url, safeError(err)))
                    .on('complete', (resp) => {
                        if (!(resp.statusCode >= 200 && resp.statusCode < 300)) {
                            this.logError('zip upload http error', url, resp.statusCode, resp.body)
                        } else {
                            this.ctx.extensionOut.appendLine('zip - http upload finished')
                        }
                    })
            )
        })

        this.ctx.extensionOut.appendLine('zip - starting')
        zip.pipe(output)
        zip.glob('./**/*.{scala,sc,sbt,java}', { cwd: rootPath })
        zip.glob('./**/.dotty-ide{.json,-artifact}', { cwd: rootPath })
        zip.finalize()
    }
開發者ID:nicolasstucki,項目名稱:dotty,代碼行數:44,代碼來源:tracer.ts

示例6: Promise

    return new Promise((resolve, reject) => {
        output.on('close', function () {
            resolve(); // the installer needs to wait for the filestream to be closed here
        });

        let archive = archiver('zip');
        archive.on('warning', function (err: any) {
            if (err.code === 'ENOENT') {
                console.log(err);
            } else {
                // throw error
                reject(err);
            }
        });

        archive.on('error', reject);
        archive.pipe(output);
        filesToAdd.forEach(elem => archive.append(elem.content, { name: elem.path }));
        archive.finalize();
    });
開發者ID:peterblazejewicz,項目名稱:omnisharp-vscode,代碼行數:20,代碼來源:CreateTestZip.ts

示例7: zipAll

    static async zipAll(): Promise<Buffer> {
        const zipPath = path.join(__dirname, '../global_data');
        const zipFile = `${zipPath}.zip`;
        if (fs.existsSync(zipFile)) {
            fs.unlinkSync(zipFile);
        }

        const output = fs.createWriteStream(zipFile);
        const archive = archiver('zip');
        let isClose = false;

        archive.on('error', (err: Error) => {
            Log.error(`zip global data error: ${err.message}`);
        });

        output.on('close', () => { isClose = true; });
        output.on('end', () => { isClose = true; });

        archive.pipe(output);
        archive.directory(zipPath, false);
        // const folders = fs.readdirSync(zipPath);
        // folders.forEach(f => {
        //     if (fs.statSync(path.join(zipPath, f)).isDirectory) {
        //         archive.directory(path.join(zipPath, f), f);
        //     }
        // });
        await archive.finalize();

        while (!isClose) {
            await new Promise((resolve, reject) => {
                setTimeout(resolve, 100);
            });
        }

        return fs.readFileSync(zipFile);
    }
開發者ID:winken168,項目名稱:Hitchhiker,代碼行數:36,代碼來源:script_transform.ts

示例8: cpy

(async () => {

  //------------------------------------
  utils.printTaskHeading('Clean');
  shell.rm('-rf', 'dist/tmp');
  shell.mkdir('-p', 'dist/tmp');

  //------------------------------------
  utils.printTaskHeading('Build frontend');
  shell.exec('npm run build', { cwd: 'frontend' });
  shell.cp('-r', 'frontend/build/.', 'plugins/versionpress/admin/public/gui');

  //------------------------------------
  utils.printTaskHeading('Copy files to dist/tmp');
  const filesToCopy = [
    '.',
    // everything except...
    '!vendor',
    '!tests',
    '!.idea',
    '!.gitignore',
    '!ruleset.xml',
  ];

  await cpy(filesToCopy, '../../dist/tmp', {
    cwd: 'plugins/versionpress',
    parents: true,
    dot: true,
  });

  //------------------------------------
  utils.printTaskHeading('Install production Composer dependencies');
  shell.exec('composer install -d dist/tmp --no-dev --prefer-dist --ignore-platform-reqs --optimize-autoloader');
  shell.rm('dist/tmp/composer.{json,lock}');

  //------------------------------------
  utils.printTaskHeading('Update version in plugin file');
  let version = shell.exec('git describe --tags').stdout.trim();

  const versionpressPhpPath = 'dist/tmp/versionpress.php';
  let content = await fs.readFile(versionpressPhpPath, { encoding: 'utf8' });
  content = content.replace(/^Version: (.*)$/m, 'Version: ' + version);
  await fs.writeFile(versionpressPhpPath, content, { encoding: 'utf8' });

  //------------------------------------
  utils.printTaskHeading('Produce ZIP file');
  const outFilePath = `dist/versionpress-${version}.zip`;
  const outFile = fs.createWriteStream(outFilePath);
  const archive = archiver('zip');
  archive.pipe(outFile);
  archive.directory('dist/tmp/', 'versionpress');
  await archive.finalize();

  //------------------------------------
  utils.printTaskHeading('Remove temp directory');
  shell.rm('-rf', 'dist/tmp');

  //------------------------------------
  utils.printTaskHeading('Done!');
  console.log(' ');
  console.log('Build ready: ' + chalk.white.bold.bgGreen(outFilePath));
  console.log(' ');

})();
開發者ID:OddenCreative,項目名稱:versionpress,代碼行數:64,代碼來源:build.ts

示例9: Date

    readableObjectMode: true,
    writeableObjectMode: true,
    decodeStrings: true,
    encoding: 'test',
    highWaterMark: 1,
    objectmode: true,
    comment: 'test',
    forceLocalTime: true,
    forceZip64: true,
    store: true,
    zlib: {},
    gzip: true,
    gzipOptions: {},
};

Archiver('zip', options);

const archiver = Archiver.create('zip');

const writeStream = fs.createWriteStream('./archiver.d.ts');
const readStream = fs.createReadStream('./archiver.d.ts');

archiver.abort();

archiver.pipe(writeStream);
archiver.append(readStream, { name: 'archiver.d.ts' });
archiver.append(readStream, { date: '05/05/1991' });
archiver.append(readStream, { date: new Date() });
archiver.append(readStream, { mode: 1 });
archiver.append(readStream, { mode: 1, stats: new fs.Stats() });
開發者ID:DavidM77,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:archiver-tests.ts


注:本文中的archiver.default方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。