本文整理汇总了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();
}
示例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));
}
示例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))
}
}
示例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;
});
}
示例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;
}
示例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();
});
示例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));
});
}
示例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);
}
});
});
示例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;
}
示例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) => {