Implemented zip, packform tasks

dependabot/npm_and_yarn/BuildServer/eslint-7.2.0
Inga 🏳‍🌈 8 years ago
parent 2b4ead8bcf
commit 0be047d7ce
  1. 15
      BuildServer/lib/tasks/packform.js
  2. 31
      BuildServer/lib/tasks/zip.js

@ -0,0 +1,15 @@
"use strict";
const sequential = require('./sequential');
module.exports = (params, processor) => sequential({
tasks: [
{
type: "zip",
params: {
directory: "",
archive: processor.context.reponame + ".zip"
}
}
]
}, processor);

@ -0,0 +1,31 @@
"use strict";
const fs = require('fs');
const path = require('path');
const Zip = require('adm-zip');
module.exports = (params, processor) => ({
process: () => {
const sourceDirectoryPath = path.normalize(processor.context.exported + "/" + (params.directory || ""));
const targetArchivePath = path.normalize(processor.context.release + "/" + params.archive);
const zip = new Zip();
processor.onInfo("Compressing '" + params.directory + "' to " + params.archive);
zip.addLocalFolder(sourceDirectoryPath);
zip.toBuffer((buffer) => {
fs.writeFile(targetArchivePath, buffer, (err) => {
if (err) {
processor.onError("Unable to write compressed data: " + err);
} else {
processor.onInfo("Compressed");
}
processor.done();
});
}, (error) => {
processor.onError("Unable to compress: " + error);
processor.done();
}, () => { }, () => { });
}
});
Loading…
Cancel
Save