@@ -263,10 +263,19 @@ public function onlyOne($tempDir = null, callable $whenOverlapping = null)
263
263
$ tempDir = $ this ->tempDir ;
264
264
}
265
265
266
- $ this ->lockFile = implode ('/ ' , [
267
- trim ($ tempDir ),
268
- trim ($ this ->id ) . '.lock ' ,
269
- ]);
266
+ if (file_exists ('/dev/null ' )){
267
+ //linux systems
268
+ $ this ->lockFile = implode ('/ ' , [
269
+ trim ($ tempDir ),
270
+ trim ($ this ->id ) . '.lock ' ,
271
+ ]);
272
+ }else {
273
+ //windows systems need back slashes for file paths
274
+ $ this ->lockFile = implode ('\\' , [
275
+ trim (str_replace ('/ ' , '\\' , $ tempDir )),
276
+ trim ($ this ->id ) . '.lock ' ,
277
+ ]);
278
+ }
270
279
271
280
if ($ whenOverlapping ) {
272
281
$ this ->whenOverlapping = $ whenOverlapping ;
@@ -303,8 +312,15 @@ public function compile()
303
312
304
313
// Add the boilerplate to redirect the output to file/s
305
314
if (count ($ this ->outputTo ) > 0 ) {
306
- $ compiled .= ' | tee ' ;
307
- $ compiled .= $ this ->outputMode === 'a ' ? '-a ' : '' ;
315
+ if (file_exists ('/dev/null ' )){
316
+ //linux systems
317
+ $ compiled .= ' | tee ' ;
318
+ $ compiled .= $ this ->outputMode === 'a ' ? '-a ' : '' ;
319
+ }else {
320
+ //windows systems
321
+ $ compiled .= ' ' ;
322
+ $ compiled .= $ this ->outputMode === 'a ' ? '>> ' : '> ' ;
323
+ }
308
324
foreach ($ this ->outputTo as $ file ) {
309
325
$ compiled .= $ file . ' ' ;
310
326
}
@@ -314,14 +330,26 @@ public function compile()
314
330
315
331
// Add boilerplate to remove lockfile after execution
316
332
if ($ this ->lockFile ) {
317
- $ compiled .= '; rm ' . $ this ->lockFile ;
333
+ if (file_exists ('/dev/null ' )){
334
+ //linux systems
335
+ $ compiled .= '; rm ' . $ this ->lockFile ;
336
+ }else {
337
+ //windows systems
338
+ $ compiled .= ' & del ' . $ this ->lockFile ;
339
+ }
318
340
}
319
341
320
342
// Add boilerplate to run in background
321
343
if ($ this ->canRunInBackground ()) {
322
344
// Parentheses are need execute the chain of commands in a subshell
323
345
// that can then run in background
324
- $ compiled = '( ' . $ compiled . ') > /dev/null 2>&1 & ' ;
346
+ if (file_exists ('/dev/null ' )){
347
+ //linux systems
348
+ $ compiled = '( ' . $ compiled . ') > /dev/null 2>&1 & ' ;
349
+ }else {
350
+ //windows systems
351
+ $ compiled = '( ' . $ compiled . ') > NUL 2>&1 ' ;
352
+ }
325
353
}
326
354
327
355
return trim ($ compiled );
0 commit comments