m19c / gulp-run

Pipe to shell commands in gulp
ISC License
151 stars 25 forks source link

Windows support #9

Closed cbarrick closed 10 years ago

cbarrick commented 10 years ago

Experimental Windows support has landed in master. The only difference is that gulp-run on Windows calls cmd.exe /c <command> instead of sh -c <command>.

Can a Windows user run the tests and report back here? The help would be very much appreciated!

krnlde commented 10 years ago

Works like a charm. I used

gulp.task('npm', function (callback) {
  run('npm install').exec(undefined, callback);
});

gulp.task('bower', function (callback) {
  run('bower install').exec(undefined, callback);
});

which works really great on Windows 8.1 node v0.10.29 (automatically calls npm.cmd which child_process.spawn doesn't)

Thanks guys.

cbarrick commented 10 years ago

Thanks for the help

TheDutchCoder commented 9 years ago

Doesn't work for commands like "mkdir -p somedir", which will actually create two directories, instead of checking if "somedir" exists.

cbarrick commented 9 years ago

There is no -p option on Windows's mkdir.

If you're trying to use a POSIX compliant mkdir, try giving it the full path to the binary, or maybe run gulp from a Cygwin shell (in which case there's no need to use the windows option in gulp-run).

TheDutchCoder commented 9 years ago

But... Why is it trying to run Windows native commands?

Isn't the whole point of this plugin to pipe commands to the shell? I'm using bash and running "mkdir -p somedir" works fine in the CLI.

If that's not the point of this plugin, would you then know what other plugin does support this?

cbarrick commented 9 years ago

By default, gulp-run uses cmd.exe on Windows instead of bash. That way it can work for all Windows users without depending on bash. You can use the full path to the mkdir binary you want to use, or change your PATH environment variable so the posix mkdir takes priority over the Windows mkdir. I think PowerShell's mkdir supports -p, so you can try the powershell option too.

cbarrick commented 9 years ago

or try bash -c mkdir -p somedir as the command

TheDutchCoder commented 9 years ago

That last command doesn't work.

I'll just resort to piping the stream to a gulp.dest(). It's not pretty but it does the job as it automatically takes care of creating a folder if it's not present.