You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
module.exports = function (fileInfo, api) { |
|
const j = api.jscodeshift |
|
const root = j(fileInfo.source) |
|
|
|
const useDoubleQuote = root.find(j.Literal).some(({ node }) => node.raw.startsWith('"')) |
|
|
|
root |
|
.find(j.Literal, { value: '@vue/app' }) |
|
.replaceWith(j.stringLiteral('@vue/cli-plugin-babel/preset')) |
|
root |
|
.find(j.Literal, { value: '@vue/babel-preset-app' }) |
|
.replaceWith(j.stringLiteral('@vue/cli-plugin-babel/preset')) |
|
|
|
const templateLiterals = root |
|
.find(j.TemplateLiteral, { |
|
expressions: { length: 0 } |
|
}) |
|
|
|
templateLiterals |
|
.find(j.TemplateElement, { |
|
value: { |
|
cooked: '@vue/app' |
|
} |
|
}) |
|
.closest(j.TemplateLiteral) |
|
.replaceWith(j.stringLiteral('@vue/cli-plugin-babel/preset')) |
|
|
|
templateLiterals |
|
.find(j.TemplateElement, { |
|
value: { |
|
cooked: '@vue/babel-preset-app' |
|
} |
|
}) |
|
.closest(j.TemplateLiteral) |
|
.replaceWith(j.stringLiteral('@vue/cli-plugin-babel/preset')) |
|
|
|
return root.toSource({ |
|
lineTerminator: '\n', |
|
quote: useDoubleQuote ? 'double' : 'single' |
|
}) |
|
}
|
|
|