Giter Site home page Giter Site logo

gulp-rev-outdated's People

Contributors

leereamsnyder avatar shonny-ua avatar tuurbo 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

Watchers

 avatar  avatar

gulp-rev-outdated's Issues

Deleting new files instead of old ones.

Hi!

I use gulp-rev, gulp-rev-collector and I love it.
But came to my attention that we need to be able to keep a certain amount of versions before deleting them permanently from the repo due to our production workflow that can take a certain amount of time to clean the caches and provide the links to the newly generated assets.

So I found your module and at start it seemed the right one that would fit my needs.
It does work, BUT, it deleted newly generated files instead of the old ones.

So I looked into your code and I cannot see the use of any manifest file. So what would you say about implementing an option that would allow to provide a manifest in order to check that it is not going to delete a file that is still in it?

Cheers,
Vincent

`.min` files are not considered valid revision

I am planning on using your module in the next release of Headstart but there seems to be an issue with the RegEx that validates stream files.

When working with development files, your module works just fine (mainly thanks to the changes you merged a few days ago), but when working with production files, meaning minified files with names as main-9d675053.min.css or core-libs-8b3d38b8.min.js, the RegEx doesn't consider them revision. It checks for -[0-9a-f]{8} followed by the extension, but fails because path.extname() doesn't include .min.

I am not an expert at RegEx, that is why I'm not just sending a PR for this, but I did test with -[0-9a-f]{8}.*? which seems to solve the problem.

Sometimes two files, sometimes one file

I'm using these tasks. On watch I run clean-css which is dependent on css. Expected result would be one file. Often I get two, sometimes I get one.

gulp.task('css', function() {
    gulp.src('site/patterns/site/site.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(autoprefixer())
        .pipe(rename('index.css'))
        .pipe(minifyCss())
        .pipe(rev())
        .pipe(gulp.dest('assets/css'))
        .pipe(rev.manifest())
        .pipe(gulp.dest('assets'))
        .pipe(notify("CSS generated!"))
    ;
});

gulp.task('clean-css', ['css'], function() {
    gulp.src( ['assets/css/index-*.css'], {read: false})
        .pipe( revOutdated(1) )
        .pipe( cleaner() );
    return;
});

Use mtime instead of ctime

I was finding most of the time it was keeping older files rather than new files. Was a little erratic though. In my case, this was because it basing latest files on ctime rather than mtime. ctime is change time and will get updated when any meta data or contents of a file changes. mtime only changes when the contents changes.

Surely we should only care about the contents being changed because a new file is always going to be created by rev when the contents change and that should superseded old files regardless of meta data.

I don't know why my build is breaking with ctime it seems strange to me thats getting updated on every build but regardless I think mtime is the more correct and stable metric to use for this purpose.

Cannot read property 'ctime' of null

Sometimes I'm getting some this error message. Does it try to read not existing file?

/Users/alexanderkozhevin/Documents/eaglefront/node_modules/gulp-rev-outdated/index.js:23
                time: file.stat.ctime.getTime()
                               ^

TypeError: Cannot read property 'ctime' of null
  at DestroyableTransform._transform (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/gulp-rev-outdated/index.js:23:32)
  at DestroyableTransform.Transform._read (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/readable-stream/lib/_stream_transform.js:159:10)
  at DestroyableTransform.Transform._write (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/readable-stream/lib/_stream_transform.js:147:83)
  at doWrite (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/readable-stream/lib/_stream_writable.js:338:64)
  at writeOrBuffer (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/readable-stream/lib/_stream_writable.js:327:5)
  at DestroyableTransform.Writable.write (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/readable-stream/lib/_stream_writable.js:264:11)
  at write (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:623:24)
  at flow (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:632:7)
  at DestroyableTransform.pipeOnReadable (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:664:5)
  at emitNone (events.js:86:13)
  at DestroyableTransform.emit (events.js:185:7)
  at emitReadable_ (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:448:10)
  at emitReadable (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:444:5)
  at readableAddChunk (/Users/alexanderkozhevin/Documents/eaglefront/node_modules/gulp/node_modules/vinyl-fs/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:187:9)

Old revisions not being removed

Hi @shonny-ua,

I can't seem to get this plugin to work as intended. Old revisions are not being removed.
Here are my two tasks. One to create revisions and one to clean them up.

function cleaner() {
    return through.obj(function(file, enc, cb){
        rimraf( path.resolve( (file.cwd || process.cwd()), file.path), function (err) {
            if (err) {
                this.emit('error', new gutil.PluginError('Cleanup old files', err));
            }
            this.push(file);
            cb();
        }.bind(this));
    });
}

gulp.task( 'rev', function() {
  // by default, gulp would pick `assets/css` as the base,
  // so we need to set it explicitly:
  gulp.src([paths.css + '/child-theme.min.css', paths.js + '/child-theme.min.js'], {base: './'})
    .pipe(rev())
    .pipe(gulp.dest('./'))  // write rev'd assets to build dir
    .pipe(rev.manifest({
        merge: true // merge with the existing manifest if one exists
    }))
    .pipe(gulp.dest('./'));  // write manifest to build dir
});

gulp.task( 'rev-clean', function() {
  gulp.src([paths.css + '/*.css'], {read: false})
    .pipe( revOutdated(2) ) // leave 2 recent assets (default value)
    .pipe( cleaner() );

    return;
});

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.