From 3b6108c1e13f94d4590ac0ea3654fc7fd0c3f89a Mon Sep 17 00:00:00 2001 From: Darryl Kuhn Date: Thu, 19 Mar 2020 23:44:24 +0000 Subject: [PATCH] feat(service): Allow mocha unit tests debugger to be bound to a specified IP and port --- packages/@vue/cli-plugin-unit-mocha/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/@vue/cli-plugin-unit-mocha/index.js b/packages/@vue/cli-plugin-unit-mocha/index.js index 2fd61f9a12..1769be92a9 100644 --- a/packages/@vue/cli-plugin-unit-mocha/index.js +++ b/packages/@vue/cli-plugin-unit-mocha/index.js @@ -37,9 +37,17 @@ module.exports = api => { `https://sysgears.github.io/mochapack/docs/installation/cli-usage.html` ) }, (args, rawArgv) => { - const inspectPos = rawArgv.indexOf('--inspect-brk') + const inspectStringPrefix = '--inspect-brk' + const matchedInspectArg = rawArgv.filter((value) => { + return (value.substring(0, inspectStringPrefix.length) === inspectStringPrefix) + }) + let nodeArgs = [] - if (inspectPos !== -1) { + + let inspectArg = '' + if (matchedInspectArg.length !== 0) { + inspectArg = matchedInspectArg[0] + const inspectPos = rawArgv.indexOf(inspectArg) nodeArgs = rawArgv.splice(inspectPos, inspectPos + 1) } // for @vue/babel-preset-app <= v4.0.0-rc.7