bundlewatch
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -6,8 +6,6 @@ "use strict"; | ||
}); | ||
exports.default = exports.normalizeFilename = exports.getPercentageChangeString = exports.getOverallDifference = void 0; | ||
exports.default = exports.getPercentageChangeString = exports.getOverallDifference = void 0; | ||
var _bytes = _interopRequireDefault(require("bytes")); | ||
var _path = require("path"); | ||
var _analyzeFiles = _interopRequireWildcard(require("./analyzeFiles")); | ||
@@ -21,8 +19,2 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
const getOverallStatus = fileResults => { | ||
@@ -116,23 +108,6 @@ return fileResults.reduce((status, fileResult) => { | ||
const normalizeFilename = normalizeFilenames => result => { | ||
var _filename$match; | ||
let filename = (0, _path.basename)(result.filePath); | ||
const [, ...matches] = (_filename$match = filename.match(normalizeFilenames)) !== null && _filename$match !== void 0 ? _filename$match : []; | ||
let normalized = filename; | ||
matches.forEach(match => { | ||
normalized = normalized.replace(match, ''); | ||
}); | ||
return _objectSpread(_objectSpread({}, result), {}, { | ||
filePath: result.filePath.slice(0, -filename.length) + normalized | ||
}); | ||
}; | ||
exports.normalizeFilename = normalizeFilename; | ||
const analyze = ({ | ||
currentBranchFileDetails, | ||
baseBranchFileDetails, | ||
baseBranchName, | ||
normalizeFilenames | ||
baseBranchName | ||
}) => { | ||
@@ -144,7 +119,2 @@ let fileResults = (0, _analyzeFiles.default)({ | ||
}); | ||
if (normalizeFilenames != null) { | ||
fileResults = fileResults.map(normalizeFilename(normalizeFilenames)); | ||
} | ||
const overallStatus = getOverallStatus(fileResults); | ||
@@ -151,0 +121,0 @@ const summary = getSummary({ |
@@ -20,3 +20,4 @@ "use strict"; | ||
files, | ||
defaultCompression | ||
defaultCompression, | ||
normalizeFilenames | ||
}) => { | ||
@@ -43,5 +44,9 @@ const fileDetails = {}; | ||
}); | ||
const normalizedFilePath = normalizeFilenames ? // remove matched capture groups | ||
filePath // find all matching segments | ||
.split(normalizeFilenames).reduce((partiallyNormalizedPath, matchingSegment) => // remove matching segment from normalized path | ||
partiallyNormalizedPath.replace(matchingSegment, ''), filePath) : filePath; | ||
if (size) { | ||
fileDetails[filePath] = { | ||
fileDetails[normalizedFilePath] = { | ||
maxSize, | ||
@@ -48,0 +53,0 @@ size, |
@@ -45,3 +45,4 @@ "use strict"; | ||
files, | ||
defaultCompression: defaultCompression | ||
defaultCompression: defaultCompression, | ||
normalizeFilenames | ||
}); | ||
@@ -65,4 +66,3 @@ const bundlewatchService = new _BundleWatchService.default({ | ||
baseBranchFileDetails, | ||
baseBranchName: ci.repoBranchBase, | ||
normalizeFilenames | ||
baseBranchName: ci.repoBranchBase | ||
}); | ||
@@ -69,0 +69,0 @@ const url = await (0, _createURL.default)({ |
{ | ||
"name": "bundlewatch", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Keep watch of your bundle size", | ||
@@ -5,0 +5,0 @@ "repository": { |
54757
1086