cssserve
Advanced tools
Comparing version 2.2.2 to 2.3.0
@@ -7,2 +7,8 @@ # Change Log | ||
## 2.3.0 | ||
_2023-04-14_ | ||
- feat: Accept `config.redirectsFile` paths as array | ||
## 2.2.2 | ||
@@ -9,0 +15,0 @@ |
{ | ||
"name": "cssserve", | ||
"version": "2.2.2", | ||
"version": "2.3.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -49,11 +49,14 @@ #!/usr/bin/env node | ||
} | ||
if (redirectsFile) { | ||
var fileContents = void 0; | ||
var redirectsFiles = Array.isArray(redirectsFile) ? redirectsFile : [redirectsFile]; | ||
redirectsFiles | ||
.filter(function (v) { return !!v; }) | ||
.forEach(function (file) { | ||
var fileContents; | ||
try { | ||
fileContents = fs.readFileSync(redirectsFile).toString(); | ||
fileContents = fs.readFileSync(file).toString(); | ||
} | ||
catch (e) { | ||
throw new Error("Could not read redirectsFile \"".concat(redirects, "\"")); | ||
throw new Error("Could not read redirectsFile \"".concat(file, "\"")); | ||
} | ||
var parsedContents = void 0; | ||
var parsedContents; | ||
try { | ||
@@ -63,18 +66,18 @@ parsedContents = JSON.parse(fileContents); | ||
catch (e) { | ||
throw new Error("Invalid JSON found in redirectsFile \"".concat(redirects, "\"")); | ||
throw new Error("Invalid JSON found in redirectsFile \"".concat(file, "\"")); | ||
} | ||
var fileRedirects_1 = ensureStringMap(parsedContents); | ||
if (!fileRedirects_1) { | ||
throw new Error("The redirectsFile \"".concat(redirects, "\" must contain a string\u2192string map")); | ||
var fileRedirects = ensureStringMap(parsedContents); | ||
if (!fileRedirects) { | ||
throw new Error("The redirectsFile \"".concat(file, "\" must contain `Record<string, string>`")); | ||
} | ||
if (redirects) { | ||
// Merge fileRedirects into redirects. | ||
Object.keys(fileRedirects_1).forEach(function (key) { | ||
redirects[key] = fileRedirects_1[key]; | ||
Object.keys(fileRedirects).forEach(function (key) { | ||
redirects[key] = fileRedirects[key]; | ||
}); | ||
} | ||
else { | ||
redirects = fileRedirects_1; | ||
redirects = fileRedirects; | ||
} | ||
} | ||
}); | ||
return redirects; | ||
@@ -114,3 +117,3 @@ }; | ||
/****************************************************************************** | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -134,3 +137,3 @@ | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) { if (Object.prototype.hasOwnProperty.call(b, p)) { d[p] = b[p]; } } }; | ||
function (d, b) { for (var p in b) { if (b.hasOwnProperty(p)) { d[p] = b[p]; } } }; | ||
return extendStatics(d, b); | ||
@@ -140,4 +143,2 @@ }; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
{ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); } | ||
extendStatics(d, b); | ||
@@ -144,0 +145,0 @@ function __() { this.constructor = d; } |
36033
677