Skip to content

Commit

Permalink
chore(NA): update code to run under last extract-zip version
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic committed Sep 29, 2020
1 parent 00e2593 commit 0a869dc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
16 changes: 6 additions & 10 deletions x-pack/plugins/reporting/server/browsers/extract/unzip.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@
import extractZip from 'extract-zip';
import { ExtractError } from './extract_error';

export function unzip(filepath, target) {
return new Promise(function (resolve, reject) {
extractZip(filepath, { dir: target }, (err) => {
if (err) {
return reject(new ExtractError(err));
}

resolve();
});
});
export async function unzip(filepath, target) {
try {
await extractZip(filepath, { dir: target });
} catch (err) {
throw new ExtractError(err);
}
}
38 changes: 19 additions & 19 deletions x-pack/plugins/security_solution/scripts/beat_docs/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,25 +135,25 @@ const convertSchemaToHash = (schema, beatFields) => {
}, beatFields);
};

const manageZipFields = async (beat, filePath, beatFields) =>
new Promise((resolve, reject) => {
extract(filePath, { dir: beat.outputDir }, (err) => {
if (err) {
return reject(new Error(err));
}
console.log('building fields', beat.index);
const obj = yaml.load(
fs.readFileSync(`${beat.outputDir}/winlogbeat-7.9.0-windows-x86_64/fields.yml`, {
encoding: 'utf-8',
})
);
const eBeatFields = convertSchemaToHash(obj, beatFields);
console.log('deleting files', beat.index);
rimraf.sync(`${beat.outputDir}/winlogbeat-7.9.0-windows-x86_64`);
rimraf.sync(beat.filePath);
resolve(eBeatFields);
});
});
const manageZipFields = async (beat, filePath, beatFields) => {
try {
await extract(filePath, { dir: beat.outputDir });
console.log('building fields', beat.index);
const obj = yaml.load(
fs.readFileSync(`${beat.outputDir}/winlogbeat-7.9.0-windows-x86_64/fields.yml`, {
encoding: 'utf-8',
})
);
const eBeatFields = convertSchemaToHash(obj, beatFields);
console.log('deleting files', beat.index);
rimraf.sync(`${beat.outputDir}/winlogbeat-7.9.0-windows-x86_64`);
rimraf.sync(beat.filePath);

return eBeatFields;
} catch (err) {
throw new Error(err);
}
};

const manageTarFields = async (beat, filePath, beatFields) =>
new Promise((resolve, reject) => {
Expand Down

0 comments on commit 0a869dc

Please sign in to comment.