chainyjs / chainy-cli

The chainy command line interface
Other
1 stars 0 forks source link

Spawn NOENT on windows #4

Open pflannery opened 10 years ago

pflannery commented 10 years ago

Because node on windows needs to specify the .cmd extension when were using spawn then commands like chainy install common fail with spawn NOENT during lines like this

if we parsed all chainy-plugin-exec command lines (windows only) with a regexp that extends the first word to include .cmd then maybe we can work around with minimal fuss.

@balupton something similar to this?

command = command.replace(/^([\\\/.:\w\-]+)/ig, "$&.cmd");
pflannery commented 10 years ago

then something like this would go here

if (process.platform === 'win32') {
    value = value.replace(/^([\\\/.:\w\-]+)/ig, "$&.cmd");
}

doing this get chainy install common working on my windows instance.

balupton commented 10 years ago

Yeah, we should use bevry/safeps for this, it'll handle it automatically.

balupton commented 10 years ago

actually, exec plugin already uses safeps... so we need to find out why safeps wasn't fixing this for us... https://github.com/chainy-plugins/exec/blob/master/lib/exec.js#L4

perhaps it's because we are giving it one string instead of an array

balupton commented 10 years ago

this is where it should work: https://github.com/bevry/safeps/blob/master/src/lib/safeps.coffee#L117-L123

pflannery commented 10 years ago

doh I didnt see your last two comments until now. It maybe because of the opts.safe not being true in the exec plugin?

I made a pr but it looks like it should handle it just not triggering ? https://github.com/bevry/safeps/pull/5

pflannery commented 10 years ago

Looking deeper I see opts.safe is set to true by default.

The real reason is because the exec path provided by chainy-cli is using absolute path which is avoided by safeps here