yargalot / gulp-accessibility

Gulp plugin for AccessSniff
48 stars 12 forks source link

Doesn't work on Windows properly #14

Open dahei opened 8 years ago

dahei commented 8 years ago

Problem:

Using this plugin under Windows, the linting fails because PhantomJS just returns

<html><head></head><body></body></html>

As it seems, PhantomJS doesn't handle full Windows paths like C:\foo\bar\index.html which gets returned from the file.path

Possible Solution:

I could make it work by hacking https://github.com/yargalot/gulp-accessibility/blob/master/index.js#L33

if (file.isBuffer()) {
      return accessSniff
        .default(fileUrl(file.path), gulpOptions) // using file-url to convert Windows path to classic file URI
        .then(function(response) {
          file.contents = new Buffer(JSON.stringify(response));

          return callback(null, file);
        })
        .catch(function(error) {
          var error = new Error(error);

          return callback(error, file);
        });
    }

You could use https://github.com/sindresorhus/file-url

The file path gets converted to something like

file:///C:/foo/bar/index.html

which is fine for PhantomJS.

I haven't tested this conversion on OS X/Linux, but it shouldn't do no harm.

Maybe there a other solutions, it was the easiest way to fix it for me.

Erbenos commented 8 years ago

Noticed this too. Exactly same issue.

jamiepreston commented 8 years ago

I was experiencing the same issue, thanks for the fix! A pull request for this addition would probably save some headaches - how about it?

yargalot commented 8 years ago

Hey guys, sorry about the delay here, im actually travelling atm so wont be able to get this out till around the 28th. Will release it asap and put some tests around it when i get back.