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

modifies binary files #2

Closed
cfoellmann opened this issue May 29, 2018 · 4 comments
Closed

modifies binary files #2

cfoellmann opened this issue May 29, 2018 · 4 comments

Comments

@cfoellmann
Copy link

When I run the gulp task across all files in my project git detects changes in binary files like .png or .mo files.
These should be untouched, right?

@iShafayet
Copy link
Owner

@cfoellmann Those should be untouched. In fact, gulp-line-ending-corrector shouldn't even have to be aware of those files. Can you post the contents of your gulpfile.js here?

@cfoellmann
Copy link
Author

var gulp = require('gulp');
var lec  = require('gulp-line-ending-corrector');

gulp.task('default', function() {});

// QA - Check for coding issues
gulp.task('qa', ['lec']);

// check encoding + line-endings
gulp.task('lec', function() {
    gulp.src(['./**/*', '!node_modules/**'])
        .pipe(lec({verbose: true, eolc: 'LF', encoding: 'utf8'}))
        .pipe(gulp.dest('./'));
});

I fixed it with this:

    // low-level equipment
var gulp = require('gulp'),                        // gulp
    isBinary = require("gulp-is-binary"),          // detect if a file is a binary
    through = require("through2"),                 // transform the stream

    // QA
    lec  = require('gulp-line-ending-corrector');  //

gulp.task('default', function() {});

// QA - Check for coding issues
gulp.task('qa', ['lec']);

// check encoding + line-endings
gulp.task('lec', function() {
    gulp.src(['./**/*', '!node_modules/**'])
        .pipe(isBinary())
        .pipe(through.obj(function(file, enc, next) {
            if (file.isBinary()) {
                next();
                return;
            }

            next(null, file);
        }))
        .pipe(lec({verbose: true, eolc: 'LF', encoding: 'utf8'}))
        .pipe(gulp.dest('./'));
});

@iShafayet
Copy link
Owner

@cfoellmann Thanks for the solution. I am going to mark this issue closed as the issue should be handled outside the plugin (like the way you did). I'll put a link to this issue in the README.md in case someone else is facing this issue.

@manzoorwanijk
Copy link

manzoorwanijk commented Sep 5, 2019

For those who are late, I solved the problem with much simpler solution using gulp-is-binary and gulp-if

import lineec from 'gulp-line-ending-corrector';
import isBinary from 'gulp-is-binary';
import gulpif from 'gulp-if';

export const fixeol = () => {
  gulp.src( [ './**/*', '!node_modules/**' ] )
    .pipe( isBinary() )
    .pipe( gulpif( file => ! file.isBinary(), lineec() ) )
    .pipe( gulp.dest( './' ) );
};

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

3 participants