Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect regexp #92

Merged
merged 1 commit into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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