Skip to content

Commit

Permalink
fix: ci
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy committed Nov 12, 2024
1 parent e58ec47 commit 75fab87
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
cache: "pnpm"

- name: Install dependencies
run: pnpm install
Expand Down
12 changes: 6 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,17 +218,17 @@ function wdm(compiler, options = {}) {
if (
Array.isArray(/** @type {MultiCompiler} */ (context.compiler).compilers)
) {
const compiler = /** @type {MultiCompiler} */ (context.compiler);
const watchOptions = compiler.compilers.map(
const multiCompiler = /** @type {MultiCompiler} */ (context.compiler);
const watchOptions = multiCompiler.compilers.map(
(childCompiler) => childCompiler.options.watchOptions || {},
);

context.watching = compiler.watch(watchOptions, errorHandler);
context.watching = multiCompiler.watch(watchOptions, errorHandler);
} else {
const compiler = /** @type {Compiler} */ (context.compiler);
const watchOptions = compiler.options.watchOptions || {};
const singleCompiler = /** @type {Compiler} */ (context.compiler);
const watchOptions = singleCompiler.options.watchOptions || {};

context.watching = compiler.watch(watchOptions, errorHandler);
context.watching = singleCompiler.watch(watchOptions, errorHandler);
}
}

Expand Down
14 changes: 10 additions & 4 deletions src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function parseHttpDate(date) {
const timestamp = date && Date.parse(date);

// istanbul ignore next: guard against date.js Date.parse patching
return typeof timestamp === "number" ? timestamp : NaN;
return typeof timestamp === "number" ? timestamp : Number.NaN;
}

const CACHE_CONTROL_NO_CACHE_REGEXP = /(?:^|,)\s*?no-cache\s*?(?:,|$)/;
Expand Down Expand Up @@ -252,6 +252,7 @@ function wrapper(context) {
}

// Send basic response
// eslint-disable-next-line no-param-reassign
res.statusCode = status;
res.setHeader("Content-Type", "text/html; charset=utf-8");
res.setHeader("Content-Security-Policy", "default-src 'none'");
Expand Down Expand Up @@ -305,12 +306,12 @@ function wrapper(context) {

// A recipient MUST ignore the If-Unmodified-Since header field if the
// received field-value is not a valid HTTP-date.
if (!isNaN(unmodifiedSince)) {
if (!Number.isNaN(unmodifiedSince)) {
const lastModified = parseHttpDate(
/** @type {string} */ (res.getHeader("Last-Modified")),
);

return isNaN(lastModified) || lastModified > unmodifiedSince;
return Number.isNaN(lastModified) || lastModified > unmodifiedSince;
}
}

Expand Down Expand Up @@ -546,6 +547,7 @@ function wrapper(context) {

// For Koa
if (res.statusCode === 404) {
// eslint-disable-next-line no-param-reassign
res.statusCode = 200;
}

Expand All @@ -558,6 +560,7 @@ function wrapper(context) {
(res.getHeader("Last-Modified")),
})
) {
// eslint-disable-next-line no-param-reassign
res.statusCode = 304;

// Remove content header fields
Expand Down Expand Up @@ -597,7 +600,8 @@ function wrapper(context) {
});

return;
} else if (parsedRanges === -2) {
}
if (parsedRanges === -2) {
context.logger.error(
"A malformed 'Range' header was provided. A regular response will be sent for this request.",
);
Expand All @@ -609,6 +613,7 @@ function wrapper(context) {

if (parsedRanges !== -2 && parsedRanges.length === 1) {
// Content-Range
// eslint-disable-next-line no-param-reassign
res.statusCode = 206;
res.setHeader(
"Content-Range",
Expand Down Expand Up @@ -648,6 +653,7 @@ function wrapper(context) {
if (req.method === "HEAD") {
// For Koa
if (res.statusCode === 404) {
// eslint-disable-next-line no-param-reassign
res.statusCode = 200;
}

Expand Down
4 changes: 3 additions & 1 deletion src/utils/getFilenameFromUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ function getFilenameFromUrl(context, url, extra = {}) {
foundFilename = filename;

break;
} else if (
}
if (
extra.stats.isDirectory() &&
(typeof options.index === "undefined" || options.index)
) {
Expand All @@ -138,6 +139,7 @@ function getFilenameFromUrl(context, url, extra = {}) {
filename = path.join(filename, indexValue);

try {
// eslint-disable-next-line no-param-reassign
extra.stats =
/** @type {import("fs").statSync} */
(context.outputFileSystem.statSync)(filename);
Expand Down
2 changes: 1 addition & 1 deletion test/middleware.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ describe.each([
undefined,
{
setupMiddlewares: (middlewares) => {
middlewares.unshift((req, res, next) => {
middlewares.unshift((_req, res, next) => {
// Express API
if (res.set) {
res.set(
Expand Down

0 comments on commit 75fab87

Please sign in to comment.