Code Monkey home page Code Monkey logo

aged's Introduction

aged

Small utility returning grunt file filter by last modified age

NPM

Build status dependencies devdependencies

endorse

I described the motivation behind this little filter in Aged to Perfection blog post.

install

npm install aged --save-dev

use

function aged(n, units, verbose)
n           - positive number
units       - time units: 'days', 'hours', 'minutes', etc
verbose     - print filename if file is too young

aged can be used to define different metrics to run on different files depending on their age. For example, to pass older, stable source files through static grunt-complexity plugin you can:

// Gruntfile.js

var aged = require('aged');
var files = ['Gruntfile.js', 'src/index.js'];

grunt.initConfig({
    complexity: {
        fresh: {
            src: files,
            options: {
                cyclomatic: 5,
                halstead: 10,
                maintainability: 100
            }
        },
        aged: {
            src: files,
            filter: aged(3, 'days', true),
            options: {
                errorsOnly: false,
                cyclomatic: 2,
                halstead: 10,
                maintainability: 100
            }
        }
    }
});

This will pass all files though less stringent fresh limits, while passing files older than 3 days though higher limits.

sample output

advanced

You can easily define the opposite filter to aged

function fresher(n, units) {
    var isAged = aged(n, units);
    return function (filename) {
        return !isAged(filename);
    };
}

Any time units are allowed, see momentjs docs.

Small print

Author: Gleb Bahmutov Copyright © 2013

License: MIT - do anything with the code, but don't blame me if it does not work.

Spread the word: tweet, star on github, etc.

Support: if you find any problems with this module, email / tweet / open issue on Github

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.