Fixes `path.resolve(false)` in `MIDDLEWARE_PATH` declaration.

未关闭
#9 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
50/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
领域
backend

调研方向

从 index.js 中 MIDDLEWARE_PATH 的声明开始,将当前对 process.argv[3] 的处理与 issue 提供的 diff 进行比较。如果可用,复现 backstop 远程 middleware 的情况,然后验证不提供 middleware path 启动时仍能正常工作,并且提供的 path 会被解析,而不会将 false 传递给 path.resolve。

由索引模型根据 Issue 内容生成。

描述

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

While debugging backstop remote I came across an issue with the middleware arg here. path.resolve doesn't accept booleans, so this splits the declaration of MIDDLEWARE_PATH into a ternary instead.

Hope this helps. Thanks for all you do!

Here is the diff that solved my problem:

diff --git a/node_modules/super-simple-web-server/index.js b/node_modules/super-simple-web-server/index.js
index 1eb8065..a27c9b9 100644
--- a/node_modules/super-simple-web-server/index.js
+++ b/node_modules/super-simple-web-server/index.js
@@ -34,7 +34,7 @@ function logger(req, res, next) {
  * To add middleware set the third arg to a path that resolves to a file exporting a function like so...
  * module.exports = (app) => { app.use(someCoolThingHere);}
  */
-const MIDDLEWARE_PATH = path.resolve(process.argv[3] || false);
+const MIDDLEWARE_PATH = process.argv[3] ? path.resolve(process.argv[3]) : false;
 if (MIDDLEWARE_PATH) {
   try {
       var initMiddleware = require(MIDDLEWARE_PATH);

This issue body was partially generated by patch-package.

主要语言
JavaScript
星标
0
派生
2
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。