Coder Social home page Coder Social logo

grunt-zopfli's People

Contributors

alrra avatar aschmitz avatar franz-josef-kaiser avatar gruntjs-updater avatar mathiasbynens avatar patrickkettner avatar shama avatar shinnn avatar tombyrer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

grunt-zopfli's Issues

Enable continuous integration (Travis)

Any ideas on how to make Travis run zopfli correctly?

Could it be done by adding something like this to .travis.yml?

before_script:
    - "# commands to download and install Zopfli go here"

Or is there a better way for this sort of thing?

Grunt 1.0.0

Getting these:

npm WARN [email protected] requires a peer of grunt@~0.4.1 but none was installed.

grunt-zopfli is the only module I can't update to a version that lives happily with newer grunt. Would you mind making a new release?

Created gzip files are corrupt

If I run zopfli.exe (with same default options, or explicitly specifying gzip), I get a functional gzip compressed file. If I use this task (default options, or explicitly specifying gzip), I get a non-functional file that is 11 bytes longer and fails gzip CRC checks.

The content of the working and non-working files appears identical except that the one generated by this task has errant newlines throughout (the zopfli.exe output has 3 lines, the grunt-zopfli output has 12. Looks like a problem in how you're writing the output stream to disk.

Dynamic path expansion does not appear to be working.

Path expansion seem to pickup the name src and places the file in the running directory.

'zopfli': {
  'images': {
    files: {
      'src': ['build/img/cards/*'],
      'dest': 'build/img/cards/compressed',
      'expand': true,
      'ext': '.png'
    }
  }
},

Gives

Running "zopfli:images" (zopfli) task
File src created.
Original: 122158 bytes.
Compressed: 121931 bytes.
File src created.
Original: 108372 bytes.
Compressed: 108142 bytes.
File src created.
Original: 114956 bytes.
Compressed: 114729 bytes.
[...]

This still works as intended though:

'zopfli': {
  'images': {
    files: {
      'build/img/cards/compressed/479.png': 'build/img/cards/479.png'
    }
  }
},

Use `execFile` instead of `exec`

@sindresorhus suggested using execFile instead of exec, because that way the input wouldn’t need to be escaped (and we could get rid of the shellwords dependency).

I tried changing this:

var zopfli = function(filePath, options, callback) {
    var command = [
        'zopfli',
        '-c',
        '--i' + options.iterations,
        options.format == 'gzip' ? '--gzip'
            : options.format == 'deflate' ? '--deflate'
                : '--zlib',
        options.splitLast ? '--splitlast' : '',
        shellEscape(filePath)
    ].join(' ');
    exec(command, function(error, stdout, stderr) {
        if (error) {
            grunt.log.warn(error);
            return;
        }
        callback.call(this, error || stderr, stdout);
    });
};

…into…

var zopfli = function(filePath, options, callback) {
    var args = [
        '-c',
        '--i' + options.iterations,
        options.format == 'gzip' ? '--gzip'
            : options.format == 'deflate' ? '--deflate'
                : '--zlib',
        options.splitLast ? '--splitlast' : '',
        filePath
    ];
    execFile('zopfli', args, function(error, stdout, stderr) {
        callback.call(this, error || stderr, stdout);
    });
};

This seems to work fine except for the fourth test in this repo’s Gruntfile.js, for which
Zopfli now throws an error:

Invalid filename: 

I have no idea why. I tried replacing the zopfli command with echo to see what the arguments looked like but they looked fine. As far as I can tell, here’s the full command that is executed for test-4:

zopfli -c --i25 --deflate  tests/fixtures/benchmark.js

I must be doing something really stupid.

option to skip .gz file name definition

Under some circumstances an option to use the same name of the source file could be a great time saving.
(ex. we're versioning our files before zopflin' them)

someting like
'': 'assets/js/*.scripts.min.js'

to get
*.scripts.min.js.gz where * here is a placeholder for the md5 hash

Enable tests for Zopfli’s non-gzip output formats (i.e. `deflate` and `zlib`)

So, grunt-zopfli runs fine for all kinds of output formats, and the unit tests confirm that the grunt-zopfli’s gzipped output is correct (i.e. it gunzips to the original file).

It’s highly unlikely that grunt-zopfli doesn’t work correctly for Zopfli’s deflate and zlib settings, since it uses the same code paths and everything — only the argument in the shell command is different. But it would be nice to have tests that confirm this.

The disabled tests are here:

// // Test disabled because I have no idea how to decompress Zopfli-generated
// // with the `zlib` setting. I thought `createInflateRaw` (inflate data
// // without zlib header) would work.
// 'test-2': function(test) {
// test.expect(1);
// decompress('tmp/test-2.js.zlib', 'zlib', function(actual) {
// test.equal(
// grunt.file.read('tests/fixtures/benchmark.js'),
// actual,
// 'Benchmark.js, 50 iterations, zlib format'
// );
// test.done();
// });
// },
// 'test-3': function(test) {
// test.expect(1);
// decompress('tmp/test-3.js.deflate', 'deflate', function(actual) {
// test.equal(
// grunt.file.read('tests/fixtures/benchmark.js'),
// actual,
// 'Benchmark.js, 10 iterations, deflate format, perform block splitting last'
// );
// test.done();
// });
// },
// 'test-4': function(test) {
// test.expect(1);
// decompress('tmp/test-4.js.deflate', 'deflate', function(actual) {
// test.equal(
// grunt.file.read('tests/fixtures/benchmark.js'),
// actual,
// 'Benchmark.js, 10 iterations, deflate format, perform block splitting first'
// );
// test.done();
// });
// },

Any ideas how to make this work? /cc @shama @aschmitz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.