From 6e546fb17bdf19e45b676cab27395318cf6a1106 Mon Sep 17 00:00:00 2001 From: fxy060608 Date: Thu, 30 Apr 2020 17:46:39 +0800 Subject: [PATCH] fix(v3): normalize windows path --- .../packages/babel-plugin-console/dist/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vue-cli-plugin-hbuilderx/packages/babel-plugin-console/dist/index.js b/packages/vue-cli-plugin-hbuilderx/packages/babel-plugin-console/dist/index.js index 7d2a87d57..8bf8b3155 100644 --- a/packages/vue-cli-plugin-hbuilderx/packages/babel-plugin-console/dist/index.js +++ b/packages/vue-cli-plugin-hbuilderx/packages/babel-plugin-console/dist/index.js @@ -1,3 +1,6 @@ +const isWin = /^win/.test(process.platform) +const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path) + const METHODS = ['error', 'warn', 'info', 'log', 'debug'] const FORMAT_LOG = '__f__' module.exports = function({ @@ -33,7 +36,7 @@ module.exports = function({ } args.push({ type: 'StringLiteral', - value: ` at ${file}:${path.node.loc.start.line}` + value: ` at ${normalizePath(file)}:${path.node.loc.start.line}` }) args.unshift(t.stringLiteral(path.node.callee.property.name)) path.replaceWith(t.callExpression(t.identifier(FORMAT_LOG), args)) -- GitLab