jharding / grunt-exec

Grunt plugin for executing shell commands.
https://npmjs.org/package/grunt-exec
Other
248 stars 47 forks source link

Grunt Exec Command with subdirectory path not working on windows #32

Closed p0wl closed 10 years ago

p0wl commented 11 years ago

I have the following command to execute using grunt (exec):

command: './node_modules/.bin/component install'

The grunt tasks fails with the following error:

image

If i execute the command in cmd (or powershell) it is working.

image

any idea? it doesn't matter if the command uses / oder \

Thanks in advance.

jharding commented 10 years ago

What if you try node node_modules/.bin/component install?

p0wl commented 10 years ago

Different error message:

image

johlrich commented 10 years ago

If i execute the command in cmd (or powershell) it is working.

@p0wl Are you sure about that? I am seeing the same error on windows, but I can only execute the command by hand within powershell, it error's with the same message about . not being a command when using cmd.

Powershell cs Cmd doesn't matter when grunt-exec issues the command, they both error for me.

(Funny enough I also ran into this when building noflo-ui-server :smile:)

johlrich commented 10 years ago

What ended up working on on both platforms was a slight variation of @jharding's suggestion node node_modules/component/bin/component install

FlorianLoch commented 10 years ago

You should try using \ instead of / on Windows - then it is working for me. But this doesn't work on Unix - so I am doing a case differentiation which isn't a really nice solution...

chesleybrown commented 10 years ago

Prepending node command before node_modules/..... worked for me, thanks @johlrich!

andrey-skl commented 10 years ago

Also you can use path.resolve or path.relative

var path = require("path");

exec: {
            bowerinstaller: path.relative("", "node_modules/.bin/bower-installer")+" -r --silent"
        },
mcandre commented 8 years ago

Could grunt-exec automatically perform path.relative translation on the first whitespace-separated token in tasks? That way, Grunt "just works" on more operating systems.

gwicksted commented 8 years ago

It could do this.. but then it would break in other situations (ie if "node" were specified before the path). grunt-exec has no way of knowing what is a path and what is an executable or argument. This is up to the user.