diff --git a/lib/index.js b/lib/index.js index c35c034..f0ea4e0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -112,8 +112,29 @@ function applyArguments (patterns, args) { * @returns {string[]} Parsed patterns. */ function parsePatterns (patternOrPatterns, args) { - const patterns = toArray(patternOrPatterns) - const hasPlaceholder = patterns.some(pattern => ARGS_PATTERN.test(pattern)) + let patterns = toArray(patternOrPatterns) + + const isNPM = process.env.npm_config_user_agent && process.env.npm_config_user_agent.startsWith('npm') + + if (!isNPM) { + // yarn | pnpm + patterns = patterns.map((pattern) => { + const match = ARGS_PATTERN.exec(pattern) + + if (!match) { + return pattern + } + + const patternList = pattern.split(' ') + const doubleDashIndex = patternList.findIndex((item) => item === '--') + patternList.splice(doubleDashIndex, 1) + pattern = patternList.join(' ') + + return pattern + }) + } + + const hasPlaceholder = patterns.some((pattern) => ARGS_PATTERN.test(pattern)) return hasPlaceholder ? applyArguments(patterns, args) : patterns }