From 7af6531d095a1b2c23154f4c860ffbed4eced210 Mon Sep 17 00:00:00 2001 From: Emilian Date: Tue, 5 Feb 2019 12:19:01 +0200 Subject: [PATCH] Added powershell support Libraries that check shims now get the powershell script too because "cmd-shim" makes on and they fail on checking if its a shim so they error out --- index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 6a22654..e2664cc 100644 --- a/index.js +++ b/index.js @@ -4,8 +4,10 @@ var fs = require('graceful-fs') function extractPath (path, cmdshimContents) { if (/[.]cmd$/.test(path)) { return extractPathFromCmd(cmdshimContents) - } else { - return extractPathFromCygwin(cmdshimContents) + } else if(/[.]ps1$/.test(path)) { + return extractPathFromPwsh(cmdshimContents) + }else{ + return extractPathFromCygwin(cmdshimContents) } } @@ -14,6 +16,11 @@ function extractPathFromCmd (cmdshimContents) { return matches && matches[1] } +function extractPathFromPwsh (cmdshimContents) { + var matches = cmdshimContents.match(/"[$]basedir[/](?!node)([^"]+?)*"/) + return matches && matches[1] +} + function extractPathFromCygwin (cmdshimContents) { var matches = cmdshimContents.match(/"[$]basedir[/]([^"]+?)"\s+"[$]@"/) return matches && matches[1]