@@ -5,7 +5,7 @@ bit = require 'bit'
55windows = ffi. os == " Windows"
66
77class TrimHandler
8- @version : 0x010000
8+ @version : 0x010001
99 @version_major : bit. rshift( @version , 16 )
1010 @version_minor : bit. band( bit. rshift( @version , 8 ) , 0xFF )
1111 @version_patch : bit. band( @version , 0xFF )
@@ -53,6 +53,7 @@ class TrimHandler
5353 -- }
5454 new : ( trimConfig ) =>
5555 @tokens = { }
56+ trimConfig. command = trimConfig. command\ gsub " [\t \r\n ]*$" , " "
5657 if trimConfig. command != nil and trimConfig. command != " "
5758 @command = trimConfig. command
5859 else
@@ -100,6 +101,7 @@ class TrimHandler
100101 [ true ] : {
101102 pre : @tokens . temp
102103 ext : " .ps1"
104+ -- This needs to be run from cmd or it will not work.
103105 exec : ' powershell -c iex "$(gc "%s" -en UTF8)"'
104106 preCom : ( @makePrefix and " mkdir -Force \" #{@tokens.prefix}\" ; & " or " & " )
105107 postCom : ( @writeLog and " 2>&1 | Out-File #{@tokens.log} -en UTF8; exit $LASTEXITCODE" or " ; exit $LASTEXITCODE" )
@@ -141,6 +143,8 @@ class TrimHandler
141143 unless encodeScriptFile
142144 log. windowError " Encoding script could not be written.\n Something is wrong with your temp dir (#{.pre})."
143145 encodeString = . preCom .. @command \ gsub( " #{(.-)}" , ( token ) -> @tokens [ token] ) .. . postCom
146+ if windows
147+ encodeString = encodeString\ gsub " `" , " ``"
144148 log. debug encodeString
145149 encodeScriptFile\ write encodeString
146150 encodeScriptFile\ close!
0 commit comments