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

Hashing fails when fed a directory #15

Open
Mossop opened this issue Nov 2, 2020 · 0 comments
Open

Hashing fails when fed a directory #15

Mossop opened this issue Nov 2, 2020 · 0 comments

Comments

@Mossop
Copy link

Mossop commented Nov 2, 2020

A straightforward glob that matches all files in a directory also ends up matching directories that this plugin then attempts and fails to hash.

Example code:

return gulp.src(path.join(__dirname, "static", "client", "**", "*"))
    .pipe(hash())
    .pipe(gulp.dest(path.join(__dirname, "build", "static")));

Result:

TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received null
    at Hash.update (internal/crypto/hash.js:84:11)
    at generateHash (/Users/dave/workspace/pixelbin/node_modules/gulp-hash-filename/lib/generateHash.js:5:8)
    at performHash (/Users/dave/workspace/pixelbin/node_modules/gulp-hash-filename/lib/performHash.js:13:13)
    at Transform.assemblyStream._transform (/Users/dave/workspace/pixelbin/node_modules/gulp-hash-filename/index.js:14:15)
    at Transform._read (_stream_transform.js:205:10)
    at Transform._write (_stream_transform.js:193:12)
    at writeOrBuffer (_stream_writable.js:352:12)
    at Transform.Writable.write (_stream_writable.js:303:10)
    at Transform.ondata (/Users/dave/workspace/pixelbin/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:681:20)
    at Transform.emit (events.js:314:20)

I can of course fix this by setting the nodir option on gulp.src but it might be good for this plugin to just skip over directories by default.

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

No branches or pull requests

1 participant