wxapkg-convertor icon indicating copy to clipboard operation
wxapkg-convertor copied to clipboard

src/wuWxapkg.js Line 158 缺陷未考虑workDir不是文件夹的情况

Open stathamcheng opened this issue 2 years ago • 1 comments

          let findDir = function (dir, oldDir) {
                let files = fs.readdirSync(dir);
                for (const file of files) {
                    let workDir = path.join(dir, file);   //此处workDir不是文件夹会导致fs.readdirSync(dir)抛异常,未考虑其处理逻辑
                    if (fs.existsSync(path.resolve(workDir, "app-service.js"))) {
                        console.log("sub package word dir: " + workDir);
                        mainDir = path.resolve(oldDir, mainDir);
                        console.log("real mainDir: " + mainDir);
                        dealThreeThings(workDir, mainDir, oldDir);
                        doSubPkg = true;
                        return true;
                    } else {
                        findDir(workDir, oldDir);
                    }
                }

            };

stathamcheng avatar Feb 03 '23 09:02 stathamcheng

而且,如果遍历完成后仍未 满足 if (fs.existsSync(path.resolve(workDir, "app-service.js"))) 条件,将会抛178行ERROR:(throw new Error("检测到此包是分包后的子包, 请通过 -s 参数指定存放路径后重试, 如 node wuWxapkg.js -s=/xxx/xxx ./testpkg/test-pkg-sub.wxapkg");)

stathamcheng avatar Feb 03 '23 09:02 stathamcheng