You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
864 B
25 lines
864 B
8 years ago
|
"use strict";
|
||
|
|
||
7 years ago
|
import fs = require("fs");
|
||
|
import path = require("path");
|
||
|
import Archiver = require("archiver");
|
||
8 years ago
|
|
||
7 years ago
|
export = (params, processor) => ({
|
||
7 years ago
|
"process": () => {
|
||
7 years ago
|
const sourceDirectoryPath = path.normalize(path.join(processor.context.exported, String(params.directory || "")));
|
||
7 years ago
|
const targetArchivePath = path.normalize(path.join(processor.context.release, params.archive));
|
||
8 years ago
|
|
||
7 years ago
|
processor.onInfo(`Compressing "${params.directory}" to "${params.archive}"`);
|
||
8 years ago
|
|
||
8 years ago
|
const output = fs.createWriteStream(targetArchivePath);
|
||
|
const archive = new Archiver("zip");
|
||
8 years ago
|
|
||
8 years ago
|
output.on("close", () => processor.done());
|
||
8 years ago
|
|
||
7 years ago
|
archive.on("error", (err) => processor.onError(`Error while compressing: ${err}`));
|
||
8 years ago
|
archive.pipe(output);
|
||
|
archive.directory(sourceDirectoryPath, false);
|
||
|
archive.finalize();
|
||
|
}
|
||
8 years ago
|
});
|