ronaldlokers / grunt-casperjs

Grunt task for casperjs
MIT License
104 stars 51 forks source link

Fatal error: spawn ENOENT when trying to run on windows #61

Open bgaborg opened 10 years ago

bgaborg commented 10 years ago

I'm getting

Fatal error: spawn ENOENT
error when running on windows.

I think the executable bat/exe file not found by node.

bgaborg commented 10 years ago

The error is that there's a missing executable in node_modules\grunt-casperjs - while on linux there's a symlink for node_modules\grunt-casperjs\lib\casperjs\casperjs-1.0.3\bin\casperjs executable, in windows it will not be available.

The fix is to handle this in windows: instead of creating a symlink to bin\casperjs, one have to create a bat file pointing at grunt-casperjs\lib\casperjs\casperjs-*\batchbin\casperjs.bat with all given arguments.

In install.js there's a

    if (process.platform != 'win32') {
        var pathToCommand = path.join(libPath, 'casperjs-' + version, 'bin', 'casperjs');
        fs.symlinkSync(pathToCommand, './casperjs');
        var stat = fs.statSync(pathToCommand);
        if (!(stat.mode & 64)) {
            fs.chmodSync(pathToCommand, '755')
        }
    }

but there is no else branch for providing compatibility for windows.