kibana/x-pack/build_chromium/create_zip.js
2018-04-24 13:49:26 -07:00

25 lines
906 B
JavaScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import path from 'path';
import rename from 'gulp-rename';
import vfs from 'vinyl-fs';
import zip from 'gulp-zip';
// we create the zip, but we want all the files to be in a folder, the zipDirectoryName,
// so we have to rename them as such
export function createZip(dir, files, zipDirectoryName, zipPath, zipFilename) {
return new Promise(function (resolve, reject) {
vfs.src(files, { cwd: dir, base: dir })
.pipe(rename(function (filePath) {
filePath.dirname = path.join(zipDirectoryName, filePath.dirname);
}))
.pipe(zip(zipFilename))
.pipe(vfs.dest(zipPath))
.on('end', resolve)
.on('error', reject);
});
}