@@ -33,34 +33,37 @@ test('env shebang', function (t) {
33
33
cmdShim ( from , to , function ( er ) {
34
34
if ( er )
35
35
throw er
36
- console . error ( '%j' , fs . readFileSync ( to , 'utf8' ) )
37
- console . error ( '%j' , fs . readFileSync ( to + '.cmd' , 'utf8' ) )
38
36
39
37
t . equal ( fs . readFileSync ( to , 'utf8' ) ,
40
- "#!/bin/sh" +
41
- "\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")" +
42
- "\n" +
43
- "\ncase `uname` in" +
44
- "\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;" +
45
- "\nesac" +
46
- "\n" +
47
- "\nif [ -x \"$basedir/node\" ]; then" +
48
- "\n \"$basedir/node\" \"$basedir/from.env\" \"$@\"" +
49
- "\n ret=$?" +
50
- "\nelse " +
51
- "\n node \"$basedir/from.env\" \"$@\"" +
52
- "\n ret=$?" +
53
- "\nfi" +
54
- "\nexit $ret" +
38
+ "#!/bin/sh" +
39
+ "\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")" +
40
+ "\n" +
41
+ "\ncase `uname` in" +
42
+ "\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;" +
43
+ "\nesac" +
44
+ "\n" +
45
+ "\nif [ -x \"$basedir/node\" ]; then" +
46
+ "\n \"$basedir/node\" \"$basedir/from.env\" \"$@\"" +
47
+ "\n ret=$?" +
48
+ "\nelse " +
49
+ "\n node \"$basedir/from.env\" \"$@\"" +
50
+ "\n ret=$?" +
51
+ "\nfi" +
52
+ "\nexit $ret" +
55
53
"\n" )
56
54
t . equal ( fs . readFileSync ( to + '.cmd' , 'utf8' ) ,
57
- "@IF EXIST \"%~dp0\\node.exe\" (\r" +
58
- "\n \"%~dp0\\node.exe\" \"%~dp0\\from.env\" %*\r" +
59
- "\n) ELSE (\r" +
60
- "\n @SETLOCAL\r" +
61
- "\n @SET PATHEXT=%PATHEXT:;.JS;=;%\r" +
62
- "\n node \"%~dp0\\from.env\" %*\r" +
63
- "\n)" )
55
+ "@SETLOCAL\r" +
56
+ "\n\r" +
57
+ "\n@IF EXIST \"%~dp0\\node.exe\" (\r" +
58
+ "\n @SET \"_prog=%~dp0\\node.exe\"\r" +
59
+ "\n) ELSE (\r" +
60
+ "\n @SET \"_prog=node\"\r" +
61
+ "\n @SET PATHEXT=%PATHEXT:;.JS;=;%\r" +
62
+ "\n)\r" +
63
+ "\n\r" +
64
+ "\n\"%_prog%\" \"%~dp0\\from.env\" %*\r" +
65
+ "\n@ENDLOCAL\r" +
66
+ "\n" )
64
67
t . end ( )
65
68
} )
66
69
} )
@@ -71,8 +74,6 @@ test('env shebang with args', function (t) {
71
74
cmdShim ( from , to , function ( er ) {
72
75
if ( er )
73
76
throw er
74
- console . error ( '%j' , fs . readFileSync ( to , 'utf8' ) )
75
- console . error ( '%j' , fs . readFileSync ( to + '.cmd' , 'utf8' ) )
76
77
77
78
t . equal ( fs . readFileSync ( to , 'utf8' ) ,
78
79
"#!/bin/sh" +
@@ -92,13 +93,18 @@ test('env shebang with args', function (t) {
92
93
"\nexit $ret" +
93
94
"\n" )
94
95
t . equal ( fs . readFileSync ( to + '.cmd' , 'utf8' ) ,
95
- "@IF EXIST \"%~dp0\\node.exe\" (\r" +
96
- "\n \"%~dp0\\node.exe\" --expose_gc \"%~dp0\\from.env.args\" %*\r" +
97
- "\n) ELSE (\r" +
98
- "\n @SETLOCAL\r" +
99
- "\n @SET PATHEXT=%PATHEXT:;.JS;=;%\r" +
100
- "\n node --expose_gc \"%~dp0\\from.env.args\" %*\r" +
101
- "\n)" )
96
+ "@SETLOCAL\r" +
97
+ "\n\r" +
98
+ "\n@IF EXIST \"%~dp0\\node.exe\" (\r" +
99
+ "\n @SET \"_prog=%~dp0\\node.exe\"\r" +
100
+ "\n) ELSE (\r" +
101
+ "\n @SET \"_prog=node\"\r" +
102
+ "\n @SET PATHEXT=%PATHEXT:;.JS;=;%\r" +
103
+ "\n)\r" +
104
+ "\n\r" +
105
+ "\n\"%_prog%\" --expose_gc \"%~dp0\\from.env.args\" %*\r" +
106
+ "\n@ENDLOCAL\r" +
107
+ "\n" )
102
108
t . end ( )
103
109
} )
104
110
} )
@@ -109,8 +115,6 @@ test('env shebang with variables', function (t) {
109
115
cmdShim ( from , to , function ( er ) {
110
116
if ( er )
111
117
throw er
112
- console . error ( '%j' , fs . readFileSync ( to , 'utf8' ) )
113
- console . error ( '%j' , fs . readFileSync ( to + '.cmd' , 'utf8' ) )
114
118
115
119
t . equal ( fs . readFileSync ( to , 'utf8' ) ,
116
120
"#!/bin/sh" +
@@ -132,14 +136,16 @@ test('env shebang with variables', function (t) {
132
136
t . equal ( fs . readFileSync ( to + '.cmd' , 'utf8' ) ,
133
137
"@SETLOCAL\r" +
134
138
"\n@SET NODE_PATH=./lib:%NODE_PATH%\r" +
139
+ "\n\r" +
135
140
"\n@IF EXIST \"%~dp0\\node.exe\" (\r" +
136
- "\n \" %~dp0\\node.exe\" \"%~dp0\\from.env.variables\" %*\r" +
141
+ "\n @SET \"_prog= %~dp0\\node.exe\"\r" +
137
142
"\n) ELSE (\r" +
138
- "\n @SETLOCAL\r" +
143
+ "\n @SET \"_prog=node\"\r" +
139
144
"\n @SET PATHEXT=%PATHEXT:;.JS;=;%\r" +
140
- "\n node \"%~dp0\\from.env.variables\" %*\r" +
141
145
"\n)\r" +
142
- "\n@ENDLOCAL" )
146
+ "\n\r" +
147
+ "\n\"%_prog%\" \"%~dp0\\from.env.variables\" %*\r" +
148
+ "\n@ENDLOCAL\r\n" )
143
149
t . end ( )
144
150
} )
145
151
} )
@@ -150,8 +156,6 @@ test('explicit shebang', function (t) {
150
156
cmdShim ( from , to , function ( er ) {
151
157
if ( er )
152
158
throw er
153
- console . error ( '%j' , fs . readFileSync ( to , 'utf8' ) )
154
- console . error ( '%j' , fs . readFileSync ( to + '.cmd' , 'utf8' ) )
155
159
156
160
t . equal ( fs . readFileSync ( to , 'utf8' ) ,
157
161
"#!/bin/sh" +
@@ -172,13 +176,18 @@ test('explicit shebang', function (t) {
172
176
"\n" )
173
177
174
178
t . equal ( fs . readFileSync ( to + '.cmd' , 'utf8' ) ,
175
- "@IF EXIST \"%~dp0\\/usr/bin/sh.exe\" (\r" +
176
- "\n \"%~dp0\\/usr/bin/sh.exe\" \"%~dp0\\from.sh\" %*\r" +
179
+ "@SETLOCAL\r" +
180
+ "\n\r" +
181
+ "\n@IF EXIST \"%~dp0\\/usr/bin/sh.exe\" (\r" +
182
+ "\n @SET \"_prog=%~dp0\\/usr/bin/sh.exe\"\r" +
177
183
"\n) ELSE (\r" +
178
- "\n @SETLOCAL\r" +
179
- "\n @SET PATHEXT=%PATHEXT:;.JS;=;%\r" +
180
- "\n /usr/bin/sh \"%~dp0\\from.sh\" %*\r" +
181
- "\n)" )
184
+ "\n @SET \"_prog=/usr/bin/sh\"\r" +
185
+ "\n @SET PATHEXT=%PATHEXT:;.JS;=;%\r" +
186
+ "\n)\r" +
187
+ "\n\r" +
188
+ "\n\"%_prog%\" \"%~dp0\\from.sh\" %*\r" +
189
+ "\n@ENDLOCAL\r" +
190
+ "\n" )
182
191
t . end ( )
183
192
} )
184
193
} )
@@ -189,8 +198,6 @@ test('explicit shebang with args', function (t) {
189
198
cmdShim ( from , to , function ( er ) {
190
199
if ( er )
191
200
throw er
192
- console . error ( '%j' , fs . readFileSync ( to , 'utf8' ) )
193
- console . error ( '%j' , fs . readFileSync ( to + '.cmd' , 'utf8' ) )
194
201
195
202
t . equal ( fs . readFileSync ( to , 'utf8' ) ,
196
203
"#!/bin/sh" +
@@ -211,13 +218,18 @@ test('explicit shebang with args', function (t) {
211
218
"\n" )
212
219
213
220
t . equal ( fs . readFileSync ( to + '.cmd' , 'utf8' ) ,
214
- "@IF EXIST \"%~dp0\\/usr/bin/sh.exe\" (\r" +
215
- "\n \"%~dp0\\/usr/bin/sh.exe\" -x \"%~dp0\\from.sh.args\" %*\r" +
221
+ "@SETLOCAL\r" +
222
+ "\n\r" +
223
+ "\n@IF EXIST \"%~dp0\\/usr/bin/sh.exe\" (\r" +
224
+ "\n @SET \"_prog=%~dp0\\/usr/bin/sh.exe\"\r" +
216
225
"\n) ELSE (\r" +
217
- "\n @SETLOCAL\r" +
218
- "\n @SET PATHEXT=%PATHEXT:;.JS;=;%\r" +
219
- "\n /usr/bin/sh -x \"%~dp0\\from.sh.args\" %*\r" +
220
- "\n)" )
226
+ "\n @SET \"_prog=/usr/bin/sh\"\r" +
227
+ "\n @SET PATHEXT=%PATHEXT:;.JS;=;%\r" +
228
+ "\n)\r" +
229
+ "\n\r" +
230
+ "\n\"%_prog%\" -x \"%~dp0\\from.sh.args\" %*\r" +
231
+ "\n@ENDLOCAL\r" +
232
+ "\n" )
221
233
t . end ( )
222
234
} )
223
235
} )
0 commit comments