From 2a34c17c85e9d71ca9a36fce183eb14c7ddc02bc Mon Sep 17 00:00:00 2001 From: EnixCoda Date: Fri, 23 Jul 2021 15:37:03 +0800 Subject: [PATCH] fix: fix pjax api logic error --- scripts/fix-pjax-api.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/fix-pjax-api.js b/scripts/fix-pjax-api.js index b20976a..b2b8b4a 100644 --- a/scripts/fix-pjax-api.js +++ b/scripts/fix-pjax-api.js @@ -9,11 +9,13 @@ function modify(source = '', pairs = []) { for (const [original, replace] of pairs) { if (source.includes(original)) { source = source.replace(original, replace) - if (source.includes(original)) { - throw new Error(`More than one original string found`, JSON.stringify(original)) - } + } else { + throw new Error(`Original string not found: ${JSON.stringify(original)}`) + } + + if (source.includes(original)) { + throw new Error(`More than one original string found`, JSON.stringify(original)) } - throw new Error(`Original string not found`, JSON.stringify(original)) } return source @@ -59,7 +61,7 @@ async function fixPJAXAPI(loose) { await fs.writeFile(filePath, modified, 'utf-8') } catch (err) { console.error((err && err.message) || err) - const shouldTerminate = true + const shouldTerminate = process.env.IGNORE_FIX_PJAX_API_FAILURE !== 'true' if (shouldTerminate) process.exit(1) } }