Files
Brandon Walderman 110d5929d1 Upgrade minimist to 1.2.6
This CL updates minimist to 1.2.6 to fix a critical security
vulnerability: https://nvd.nist.gov/vuln/detail/CVE-2021-44906

The fix was made by running:
`npm run install-deps audit fix --audit-level=critical`

Bug: none
Change-Id: I51103b525d9969e03000d55af86cebdabc7e0366
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3591079
Reviewed-by: Mathias Bynens <mathias@chromium.org>
Commit-Queue: Brandon Walderman <brwalder@microsoft.com>
2022-04-20 06:33:45 +00:00

40 lines
964 B
JavaScript

const debug = require("debug")("streamroller:fileNameFormatter");
const path = require("path");
const ZIP_EXT = ".gz";
const DEFAULT_FILENAME_SEP = ".";
module.exports = ({
file,
keepFileExt,
needsIndex,
alwaysIncludeDate,
compress,
fileNameSep
}) => {
let FILENAME_SEP = fileNameSep || DEFAULT_FILENAME_SEP;
const dirAndName = path.join(file.dir, file.name);
const ext = f => f + file.ext;
const index = (f, i, d) =>
(needsIndex || !d) && i ? f + FILENAME_SEP + i : f;
const date = (f, i, d) => {
return (i > 0 || alwaysIncludeDate) && d ? f + FILENAME_SEP + d : f;
};
const gzip = (f, i) => (i && compress ? f + ZIP_EXT : f);
const parts = keepFileExt
? [date, index, ext, gzip]
: [ext, date, index, gzip];
return ({ date, index }) => {
debug(`_formatFileName: date=${date}, index=${index}`);
return parts.reduce(
(filename, part) => part(filename, index, date),
dirAndName
);
};
};