From 901eee8a37cc5176263f8e15e23edef63e9603e9 Mon Sep 17 00:00:00 2001 From: KonpekiCode <512054675@qq.com> Date: Mon, 28 Mar 2022 11:23:19 +0800 Subject: [PATCH] fix: incorrect regexp (#92) --- src/ast-parse/parsers/findHtmlConfigProperties.ts | 4 ++-- src/ast-parse/parsers/findHtmlPluginChain.ts | 4 ++-- src/ast-parse/parsers/findRequireContext.ts | 4 ++-- src/ast-parse/parsers/findWebpackConfigProperties.ts | 4 ++-- src/ast-parse/transformations/chainWebpackTransformation.ts | 2 +- .../transformations/indexHtmlTransformationVueCli.ts | 2 +- .../transformations/indexHtmlTransformationWebpack.ts | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ast-parse/parsers/findHtmlConfigProperties.ts b/src/ast-parse/parsers/findHtmlConfigProperties.ts index 0d401cf..893af91 100644 --- a/src/ast-parse/parsers/findHtmlConfigProperties.ts +++ b/src/ast-parse/parsers/findHtmlConfigProperties.ts @@ -11,13 +11,13 @@ import { parseIdentifierFromBodyNodes, parseScriptSfc } from '../../utils/astUti export const astParse: ASTParse = (fileInfo: FileInfo) => { let nodePaths: Node[] - if (/vue.config.js$/.test(fileInfo.path)) { + if (/vue\.config\.js$/.test(fileInfo.path)) { const context = parseScriptSfc(fileInfo) if (!context || !context.__paths) { return null } nodePaths = context.__paths - } else if (/vue.config.ts$/.test(fileInfo.path)) { + } else if (/vue\.config\.ts$/.test(fileInfo.path)) { const context = parseScriptSfc(fileInfo, 'ts') if (!context || !context.__paths) { return null diff --git a/src/ast-parse/parsers/findHtmlPluginChain.ts b/src/ast-parse/parsers/findHtmlPluginChain.ts index 638795f..b8fa1e6 100644 --- a/src/ast-parse/parsers/findHtmlPluginChain.ts +++ b/src/ast-parse/parsers/findHtmlPluginChain.ts @@ -12,13 +12,13 @@ import { recordConver } from '../../utils/report' export const astParse: ASTParse = (fileInfo: FileInfo) => { let nodePaths: Node[] - if (/vue.config.js$/.test(fileInfo.path)) { + if (/vue\.config\.js$/.test(fileInfo.path)) { const context = parseScriptSfc(fileInfo) if (!context || !context.__paths) { return null } nodePaths = context.__paths - } else if (/vue.config.ts$/.test(fileInfo.path)) { + } else if (/vue\.config\.ts$/.test(fileInfo.path)) { const context = parseScriptSfc(fileInfo, 'ts') if (!context || !context.__paths) { return null diff --git a/src/ast-parse/parsers/findRequireContext.ts b/src/ast-parse/parsers/findRequireContext.ts index 87030c0..024e1a8 100644 --- a/src/ast-parse/parsers/findRequireContext.ts +++ b/src/ast-parse/parsers/findRequireContext.ts @@ -11,13 +11,13 @@ import { parseVueSfc, parseScriptSfc } from '../../utils/astUtils' export const astParse: ASTParse = (fileInfo: FileInfo) => { let nodePaths: Node[] - if (/.vue$/.test(fileInfo.path)) { + if (/\.vue$/.test(fileInfo.path)) { const context: VueSFCContext = parseVueSfc(fileInfo) if (!context.scriptAST || !context.scriptAST.__paths) { return null } nodePaths = context.scriptAST.__paths - } else if (/.ts$/.test(fileInfo.path)) { + } else if (/\.ts$/.test(fileInfo.path)) { const context = parseScriptSfc(fileInfo, 'ts') if (!context || !context.__paths) { return null diff --git a/src/ast-parse/parsers/findWebpackConfigProperties.ts b/src/ast-parse/parsers/findWebpackConfigProperties.ts index 6207e87..f88af61 100644 --- a/src/ast-parse/parsers/findWebpackConfigProperties.ts +++ b/src/ast-parse/parsers/findWebpackConfigProperties.ts @@ -11,13 +11,13 @@ import { parseIdentifierFromBodyNodes, parseScriptSfc } from '../../utils/astUti export const astParse: ASTParse = (fileInfo: FileInfo) => { let nodePaths: Node[] - if (/vue.config.js$/.test(fileInfo.path)) { + if (/vue\.config\.js$/.test(fileInfo.path)) { const context = parseScriptSfc(fileInfo) if (!context || !context.__paths) { return null } nodePaths = context.__paths - } else if (/vue.config.ts$/.test(fileInfo.path)) { + } else if (/vue\.config\.ts$/.test(fileInfo.path)) { const context = parseScriptSfc(fileInfo, 'ts') if (!context || !context.__paths) { return null diff --git a/src/ast-parse/transformations/chainWebpackTransformation.ts b/src/ast-parse/transformations/chainWebpackTransformation.ts index 5992bf8..b852548 100644 --- a/src/ast-parse/transformations/chainWebpackTransformation.ts +++ b/src/ast-parse/transformations/chainWebpackTransformation.ts @@ -22,7 +22,7 @@ export const astTransform: ASTTransformation = async ( if (transformationParams.config.projectType === 'webpack') { return null } - if (!/vue.config.(js|ts)$/.test(fileInfo.path)) { + if (!/vue\.config\.(js|ts)$/.test(fileInfo.path)) { return null } diff --git a/src/ast-parse/transformations/indexHtmlTransformationVueCli.ts b/src/ast-parse/transformations/indexHtmlTransformationVueCli.ts index 62a294d..4180ac7 100644 --- a/src/ast-parse/transformations/indexHtmlTransformationVueCli.ts +++ b/src/ast-parse/transformations/indexHtmlTransformationVueCli.ts @@ -145,7 +145,7 @@ export const astTransform: ASTTransformation = async ( recordConver({ num: 'V06', feat: 'client-side env variables' }) // use vite-plugin-html to replace html-webpack-plugin - transformedHtml = transformedHtml.replace(/htmlWebpackPlugin.(options|files)./g, '') + transformedHtml = transformedHtml.replace(/htmlWebpackPlugin\.(options|files)\./g, '') const result: TransformationResult = { fileInfo: fileInfo, diff --git a/src/ast-parse/transformations/indexHtmlTransformationWebpack.ts b/src/ast-parse/transformations/indexHtmlTransformationWebpack.ts index 4ca78d8..74a8f24 100644 --- a/src/ast-parse/transformations/indexHtmlTransformationWebpack.ts +++ b/src/ast-parse/transformations/indexHtmlTransformationWebpack.ts @@ -150,7 +150,7 @@ export const astTransform: ASTTransformation = async ( }) // use vite-plugin-html to replace html-webpack-plugin - transformedHtml = transformedHtml.replace(/htmlWebpackPlugin.(options|files)./g, '') + transformedHtml = transformedHtml.replace(/htmlWebpackPlugin\.(options|files)\./g, '') const result: TransformationResult = { fileInfo: fileInfo,