Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue in extract on zero size files #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nipr-ejohnson1
Copy link

Just like issue #49, the extract method needs to check to make sure it does not call the .toString method on anything that has a zero length such as directories. Issue was on a Windows box if that makes any difference while testing.

gulpfile.js, paths.html.input is a series of nested directories:

gulp.task('lint:scripts', function () {
    return gulp.src([paths.scripts.input, paths.html.input])
        .pipe(plumber())
        .pipe(jshint.extract('always'))
        .pipe(jshint())
        .pipe(jshint.reporter(jshintReporter))
        .on('end', jshintReporter.writeFile({
            format: 'checkstyle',
            filePath: './dist/reports/checkstyle-js.xml'
        }));
});

Stack:

      file.jshint.extracted = jshintcli.extract(file.contents.toString('utf8'), when);
                                                             ^

TypeError: Cannot read property 'toString' of null
    at C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\src\extract.js:15:62
    at module.exports._.memoize.Minimatch.nocase (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\src\fileIgn
ored.js:38:7)
    at DestroyableTransform.<anonymous> (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\src\extract.js:10:5)

    at DestroyableTransform._transform (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\src\stream.js:26:15)
    at DestroyableTransform.Transform._read (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\node_modules\rea
dable-stream\lib\_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\node_modules\re
adable-stream\lib\_stream_transform.js:172:12)
    at doWrite (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\node_modules\readable-stream\lib\_stream_writ
able.js:237:10)
    at writeOrBuffer (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\node_modules\readable-stream\lib\_strea
m_writable.js:227:5)
    at DestroyableTransform.Writable.write (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\node_modules\read
able-stream\lib\_stream_writable.js:194:11)
    at DestroyableTransform.ondata (C:\data\workspace\eclipse\my-nipr\node_modules\through2\node_modules\readable-stream
\lib\_stream_readable.js:531:20)

Just like issue spalger#49, the extract method needs to check to make sure it does not call the `.toString` method on anything that has a zero length such as directories. Issue was on a Windows box if that makes any difference while testing.

Stack:
      file.jshint.extracted = jshintcli.extract(file.contents.toString('utf8'), when);
                                                             ^

TypeError: Cannot read property 'toString' of null
    at C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\src\extract.js:15:62
    at module.exports._.memoize.Minimatch.nocase (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\src\fileIgn
ored.js:38:7)
    at DestroyableTransform.<anonymous> (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\src\extract.js:10:5)

    at DestroyableTransform._transform (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\src\stream.js:26:15)
    at DestroyableTransform.Transform._read (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\node_modules\rea
dable-stream\lib\_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\node_modules\re
adable-stream\lib\_stream_transform.js:172:12)
    at doWrite (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\node_modules\readable-stream\lib\_stream_writ
able.js:237:10)
    at writeOrBuffer (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\node_modules\readable-stream\lib\_strea
m_writable.js:227:5)
    at DestroyableTransform.Writable.write (C:\data\workspace\eclipse\my-nipr\node_modules\gulp-jshint\node_modules\read
able-stream\lib\_stream_writable.js:194:11)
    at DestroyableTransform.ondata (C:\data\workspace\eclipse\my-nipr\node_modules\through2\node_modules\readable-stream
\lib\_stream_readable.js:531:20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant