Skip to content

Commit

Permalink
fix: incorrect regexp (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
konpeki622 committed Mar 28, 2022
1 parent 7401c37 commit 901eee8
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/ast-parse/parsers/findHtmlConfigProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/ast-parse/parsers/findHtmlPluginChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/ast-parse/parsers/findRequireContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/ast-parse/parsers/findWebpackConfigProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 901eee8

Please sign in to comment.