<commit_before>var opts = {mock: true};
var authenticationService = require('./services/authentication.js')(opts);
var themeService = require('./services/theme.js')(opts);
var homeService = require('./services/home.js')(opts);
var notificationsService = require('./services/notification.js')(opts);
var todoService = require('./services/todo.js')(opts);
var analyticService = require('./services/analytic.js')(opts);
var documentService = require('./services/document.js')(opts);

module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        clean: ['.grunt', 'dist'],
        jslint: {
            client: {
                src: ['public/javascripts/**/*.js'],
                directives: {
                    predef: [
                        'angular'
                    ],
                    plusplus: true
                }
            }
        },
        closurecompiler: {
            minify: {
                files: {
                    'dist/javascripts/<%= pkg.name %>-<%= pkg.version %>.min.js': [
                        // Shared
                        'public/javascripts/shared/shared-module.js',
                        'public/javascripts/shared/**/shared-*.js',
                        // Login
                        'public/javascripts/index/login/login-module.js',
                        'public/javascripts/index/login/**/login-*.js',
                        // Home
                        'public/javascripts/index/main/home/home-module.js',
                        'public/javascripts/index/main/home/**/home-*.js',
                        // Apps
                        'public/javascripts/index/main/apps/apps-module.js',
                        'public/javascripts/index/main/apps/**/apps-*.js',
                        // Todos
                        'public/javascripts/index/main/todos/todos-module.js',
                        'public/javascripts/index/main/todos/**/todos-*.js',
                        // Notifications
                        'public/javascripts/index/main/notifications/notifications-module.js',
                        'public/javascripts/index/main/notifications/**/notifications-*.js',
                        // Analytics
                        'public/javascripts/index/main/analytics/analytics-module.js',
                        'public/javascripts/index/main/analytics/**/analytics-*.js',
                        // Documents
                        'public/javascripts/index/main/documents/documents-module.js',
                        'public/javascripts/index/main/documents/**/documents-*.js',
                        // Main
                        'public/javascripts/index/main/main-module.js',
                        'public/javascripts/index/main/**/main-*.js',
                        // Index
                        'public/javascripts/index/index-module.js'
                    ]
                },
                options: {
                    'banner': '/* <%= pkg.name %>-<%= pkg.version %> */'
                    //'compilation_level': 'ADVANCED_OPTIMIZATIONS',
                    //'create_source_map': '<%= pkg.name %>-<%= pkg.version %>.min.js.map'
                }
            }
        },
        jade: {
            compile: {
                options: {
                    pretty: true,
                    data: {
                        bootstrap: JSON.stringify({
                            dir: 'ltr',
                            locale: 'en',
                            theme: 'default',
                            user: null
                        }),
                        stylesheets: [
                            'stylesheets/bootstrap.min.css',
                            'stylesheets/<%= pkg.name %>-<%= pkg.version %>.min.css'
                        ],
                        javascripts: [
                            'javascripts/angular.min.js',
                            'javascripts/angular-animate.min.js',
                            'javascripts/angular-route.min.js',
                            'javascripts/<%= pkg.name %>-<%= pkg.version %>.min.js'
                        ]
                    }
                },
                files: {
                    'dist/index.html': ['views/index.jade']
                }
            }
        },
        less: {
            dist: {
                options: {
                    rootpath: '../',
                    compress: true,
                    ieCompat: false,
                    preprocess: function(src) {
                        return '@import "public/stylesheets/themes/default/less/variables.less";\n'+ src;
                    }
                },
                files: {
                    'public/stylesheets/themes/default/index/login/login.css': 'public/stylesheets/index/login/login.less',
                    'public/stylesheets/themes/default/index/main/main.css': 'public/stylesheets/index/main/main.less',
                    'public/stylesheets/themes/default/index/main/home/home.css': 'public/stylesheets/index/main/home/home.less',
                    'public/stylesheets/themes/default/index/main/apps/apps.css': 'public/stylesheets/index/main/apps/apps.less',
                    'public/stylesheets/themes/default/index/main/todos/todos.css': 'public/stylesheets/index/main/todos/todos.less',
                    'public/stylesheets/themes/default/index/main/notifications/notifications.css': 'public/stylesheets/index/main/notifications/notifications.less',
                    'public/stylesheets/themes/default/index/main/analytics/analytics.css': 'public/stylesheets/index/main/analytics/analytics.less',
                    'public/stylesheets/themes/default/index/main/documents/documents.css': 'public/stylesheets/index/main/documents/documents.less'
                }
            }
        },
        cssmin: {
            combine: {
                files: {
                    'dist/stylesheets/<%= pkg.name %>-<%= pkg.version %>.min.css': [
                        'public/stylesheets/themes/default/index/login/login.css',
                        'public/stylesheets/themes/default/index/main/main.css',
                        'public/stylesheets/themes/default/index/main/*/*.css'
                    ]
                }
            }
        },
        copy: {
            main: {
                files: [{
                    expand: true,
                    flatten: true,
                    src: [
                        'bower_components/angular/angular.min.js',
                        'bower_components/angular/angular.min.js.map',
                        'bower_components/angular-animate/angular-animate.min.js',
                        'bower_components/angular-animate/angular-animate.min.js.map',
                        'bower_components/angular-route/angular-route.min.js',
                        'bower_components/angular-route/angular-route.min.js.map'
                    ],
                    dest: 'dist/javascripts/'
                }, {
                    expand: true,
                    cwd: 'public/stylesheets/themes/default/css',
                    src: ['**'],
                    dest: 'dist/stylesheets/'
                }, {
                    expand: true,
                    cwd: 'public/images/',
                    src: ['**'],
                    dest: 'dist/images/'
                }, {
                    expand: true,
                    cwd: 'public/images/shared/',
                    src: ['favicon.png'],
                    dest: 'dist/'
                }, {
                    expand: true,
                    flatten: true,
                    src: [
                        'public/stylesheets/themes/default/fonts/*'
                    ],
                    dest: 'dist/fonts/'
                }, {
                    expand: true,
                    cwd: 'public/partials/',
                    src: ['**'],
                    dest: 'dist/partials/'
                }]
            }
        },
        'string-replace': {
            css: {
                options: {
                    replacements: [{
                        pattern: /\(\/images\//gm,
                        replacement: '(../images/'
                    }]
                },
                files: {
                    'dist/stylesheets/<%= pkg.name %>-<%= pkg.version %>.min.css': 'dist/stylesheets/<%= pkg.name %>-<%= pkg.version %>.min.css'
                }
            },
            js: {
                options: {
                    replacements: [{
                        pattern: /\.post\(/gm,
                        replacement: '.get('
                    }]
                },
                files: {
                    'dist/javascripts/<%= pkg.name %>-<%= pkg.version %>.min.js': 'dist/javascripts/<%= pkg.name %>-<%= pkg.version %>.min.js'
                }
            }
        },
        'file-creator': {
            api: {
                "dist/api/themes": function (fs, fd, done) {
                    var data = themeService.getThemes();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/login": function (fs, fd, done) {
                    var data = authenticationService.login();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/logout": function (fs, fd, done) {
                    var data = authenticationService.logout();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/home/widgets": function (fs, fd, done) {
                    var data = homeService.getWidgets();
                    fs.mkdirSync("dist/api/home/widget");
                    JSON.parse(data).results.forEach(function(item) {
                        fs.mkdirSync("dist/api/home/widget/" + item.widgetId);
                        fs.mkdirSync("dist/api/home/widget/" + item.widgetId + "/document");
                        fs.writeFileSync(
                            "dist/api/home/widget/" + item.widgetId + "/document/" + item.documentId,
                            homeService.getWidget({
                                params: {
                                    widgetId: item.widgetId
                                }
                            })
                        );
                    });
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/notifications": function (fs, fd, done) {
                    var data = notificationsService.getNotifications();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/todos": function (fs, fd, done) {
                    var data = todoService.getTodos();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/reports": function (fs, fd, done) {
                    var data = analyticService.getReports();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/documents": function (fs, fd, done) {
                    var data = documentService.getDocuments();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                }
            }
        },
        'gh-pages': {
            local: {
                options: {
                    base: 'dist',
                    message: 'Generate gh-pages with Grunt task gh-pages:local'
                },
                src: ['**']
            },
            travis: {
                options: {
                    repo: 'https://' + process.env.GH_TOKEN + '@github.com/micellius/sap-one-experience.git',
                    base: 'dist',
                    message: 'Generate gh-pages with Grunt task gh-pages:travis',
                    user: {
                        name: 'Travis CI',
                        email: 'travis@localhost.localdomain'
                    },
                    silent: true
                },
                src: ['**']
            }
        }
    });

    grunt.loadNpmTasks('grunt-jslint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-closurecompiler');
    grunt.loadNpmTasks('grunt-contrib-jade');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-string-replace');
    grunt.loadNpmTasks('grunt-file-creator');
    grunt.loadNpmTasks('grunt-gh-pages');

    grunt.registerTask('build', [
        'jslint',
        'clean',
        'closurecompiler',
        'jade',
        'less',
        'cssmin',
        'copy',
        'string-replace',
        'file-creator'
    ]);
    grunt.registerTask('publish', ['gh-pages:local']);
    grunt.registerTask('default', ['build']);

};<commit_msg>Standalone: generate mock apps feed<commit_after>var opts = {mock: true};
var authenticationService = require('./services/authentication.js')(opts);
var themeService = require('./services/theme.js')(opts);
var homeService = require('./services/home.js')(opts);
var notificationsService = require('./services/notification.js')(opts);
var todoService = require('./services/todo.js')(opts);
var analyticService = require('./services/analytic.js')(opts);
var documentService = require('./services/document.js')(opts);
var appService = require('./services/app.js')(opts);

module.exports = function(grunt) {

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        clean: ['.grunt', 'dist'],
        jslint: {
            client: {
                src: ['public/javascripts/**/*.js'],
                directives: {
                    predef: [
                        'angular'
                    ],
                    plusplus: true
                }
            }
        },
        closurecompiler: {
            minify: {
                files: {
                    'dist/javascripts/<%= pkg.name %>-<%= pkg.version %>.min.js': [
                        // Shared
                        'public/javascripts/shared/shared-module.js',
                        'public/javascripts/shared/**/shared-*.js',
                        // Login
                        'public/javascripts/index/login/login-module.js',
                        'public/javascripts/index/login/**/login-*.js',
                        // Home
                        'public/javascripts/index/main/home/home-module.js',
                        'public/javascripts/index/main/home/**/home-*.js',
                        // Apps
                        'public/javascripts/index/main/apps/apps-module.js',
                        'public/javascripts/index/main/apps/**/apps-*.js',
                        // Todos
                        'public/javascripts/index/main/todos/todos-module.js',
                        'public/javascripts/index/main/todos/**/todos-*.js',
                        // Notifications
                        'public/javascripts/index/main/notifications/notifications-module.js',
                        'public/javascripts/index/main/notifications/**/notifications-*.js',
                        // Analytics
                        'public/javascripts/index/main/analytics/analytics-module.js',
                        'public/javascripts/index/main/analytics/**/analytics-*.js',
                        // Documents
                        'public/javascripts/index/main/documents/documents-module.js',
                        'public/javascripts/index/main/documents/**/documents-*.js',
                        // Main
                        'public/javascripts/index/main/main-module.js',
                        'public/javascripts/index/main/**/main-*.js',
                        // Index
                        'public/javascripts/index/index-module.js'
                    ]
                },
                options: {
                    'banner': '/* <%= pkg.name %>-<%= pkg.version %> */'
                    //'compilation_level': 'ADVANCED_OPTIMIZATIONS',
                    //'create_source_map': '<%= pkg.name %>-<%= pkg.version %>.min.js.map'
                }
            }
        },
        jade: {
            compile: {
                options: {
                    pretty: true,
                    data: {
                        bootstrap: JSON.stringify({
                            dir: 'ltr',
                            locale: 'en',
                            theme: 'default',
                            user: null
                        }),
                        stylesheets: [
                            'stylesheets/bootstrap.min.css',
                            'stylesheets/<%= pkg.name %>-<%= pkg.version %>.min.css'
                        ],
                        javascripts: [
                            'javascripts/angular.min.js',
                            'javascripts/angular-animate.min.js',
                            'javascripts/angular-route.min.js',
                            'javascripts/<%= pkg.name %>-<%= pkg.version %>.min.js'
                        ]
                    }
                },
                files: {
                    'dist/index.html': ['views/index.jade']
                }
            }
        },
        less: {
            dist: {
                options: {
                    rootpath: '../',
                    compress: true,
                    ieCompat: false,
                    preprocess: function(src) {
                        return '@import "public/stylesheets/themes/default/less/variables.less";\n'+ src;
                    }
                },
                files: {
                    'public/stylesheets/themes/default/index/login/login.css': 'public/stylesheets/index/login/login.less',
                    'public/stylesheets/themes/default/index/main/main.css': 'public/stylesheets/index/main/main.less',
                    'public/stylesheets/themes/default/index/main/home/home.css': 'public/stylesheets/index/main/home/home.less',
                    'public/stylesheets/themes/default/index/main/apps/apps.css': 'public/stylesheets/index/main/apps/apps.less',
                    'public/stylesheets/themes/default/index/main/todos/todos.css': 'public/stylesheets/index/main/todos/todos.less',
                    'public/stylesheets/themes/default/index/main/notifications/notifications.css': 'public/stylesheets/index/main/notifications/notifications.less',
                    'public/stylesheets/themes/default/index/main/analytics/analytics.css': 'public/stylesheets/index/main/analytics/analytics.less',
                    'public/stylesheets/themes/default/index/main/documents/documents.css': 'public/stylesheets/index/main/documents/documents.less'
                }
            }
        },
        cssmin: {
            combine: {
                files: {
                    'dist/stylesheets/<%= pkg.name %>-<%= pkg.version %>.min.css': [
                        'public/stylesheets/themes/default/index/login/login.css',
                        'public/stylesheets/themes/default/index/main/main.css',
                        'public/stylesheets/themes/default/index/main/*/*.css'
                    ]
                }
            }
        },
        copy: {
            main: {
                files: [{
                    expand: true,
                    flatten: true,
                    src: [
                        'bower_components/angular/angular.min.js',
                        'bower_components/angular/angular.min.js.map',
                        'bower_components/angular-animate/angular-animate.min.js',
                        'bower_components/angular-animate/angular-animate.min.js.map',
                        'bower_components/angular-route/angular-route.min.js',
                        'bower_components/angular-route/angular-route.min.js.map'
                    ],
                    dest: 'dist/javascripts/'
                }, {
                    expand: true,
                    cwd: 'public/stylesheets/themes/default/css',
                    src: ['**'],
                    dest: 'dist/stylesheets/'
                }, {
                    expand: true,
                    cwd: 'public/images/',
                    src: ['**'],
                    dest: 'dist/images/'
                }, {
                    expand: true,
                    cwd: 'public/images/shared/',
                    src: ['favicon.png'],
                    dest: 'dist/'
                }, {
                    expand: true,
                    flatten: true,
                    src: [
                        'public/stylesheets/themes/default/fonts/*'
                    ],
                    dest: 'dist/fonts/'
                }, {
                    expand: true,
                    cwd: 'public/partials/',
                    src: ['**'],
                    dest: 'dist/partials/'
                }]
            }
        },
        'string-replace': {
            css: {
                options: {
                    replacements: [{
                        pattern: /\(\/images\//gm,
                        replacement: '(../images/'
                    }]
                },
                files: {
                    'dist/stylesheets/<%= pkg.name %>-<%= pkg.version %>.min.css': 'dist/stylesheets/<%= pkg.name %>-<%= pkg.version %>.min.css'
                }
            },
            js: {
                options: {
                    replacements: [{
                        pattern: /\.post\(/gm,
                        replacement: '.get('
                    }]
                },
                files: {
                    'dist/javascripts/<%= pkg.name %>-<%= pkg.version %>.min.js': 'dist/javascripts/<%= pkg.name %>-<%= pkg.version %>.min.js'
                }
            }
        },
        'file-creator': {
            api: {
                "dist/api/themes": function (fs, fd, done) {
                    var data = themeService.getThemes();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/login": function (fs, fd, done) {
                    var data = authenticationService.login();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/logout": function (fs, fd, done) {
                    var data = authenticationService.logout();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/home/widgets": function (fs, fd, done) {
                    var data = homeService.getWidgets();
                    fs.mkdirSync("dist/api/home/widget");
                    JSON.parse(data).results.forEach(function(item) {
                        fs.mkdirSync("dist/api/home/widget/" + item.widgetId);
                        fs.mkdirSync("dist/api/home/widget/" + item.widgetId + "/document");
                        fs.writeFileSync(
                            "dist/api/home/widget/" + item.widgetId + "/document/" + item.documentId,
                            homeService.getWidget({
                                params: {
                                    widgetId: item.widgetId
                                }
                            })
                        );
                    });
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/apps/groups": function (fs, fd, done) {
                    var data = appService.getGroups();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/notifications": function (fs, fd, done) {
                    var data = notificationsService.getNotifications();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/todos": function (fs, fd, done) {
                    var data = todoService.getTodos();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/reports": function (fs, fd, done) {
                    var data = analyticService.getReports();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                },
                "dist/api/documents": function (fs, fd, done) {
                    var data = documentService.getDocuments();
                    fs.write(fd, new Buffer(data), 0, data.length, 0, done);
                }
            }
        },
        'gh-pages': {
            local: {
                options: {
                    base: 'dist',
                    message: 'Generate gh-pages with Grunt task gh-pages:local'
                },
                src: ['**']
            },
            travis: {
                options: {
                    repo: 'https://' + process.env.GH_TOKEN + '@github.com/micellius/sap-one-experience.git',
                    base: 'dist',
                    message: 'Generate gh-pages with Grunt task gh-pages:travis',
                    user: {
                        name: 'Travis CI',
                        email: 'travis@localhost.localdomain'
                    },
                    silent: true
                },
                src: ['**']
            }
        }
    });

    grunt.loadNpmTasks('grunt-jslint');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-closurecompiler');
    grunt.loadNpmTasks('grunt-contrib-jade');
    grunt.loadNpmTasks('grunt-contrib-less');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-string-replace');
    grunt.loadNpmTasks('grunt-file-creator');
    grunt.loadNpmTasks('grunt-gh-pages');

    grunt.registerTask('build', [
        'jslint',
        'clean',
        'closurecompiler',
        'jade',
        'less',
        'cssmin',
        'copy',
        'string-replace',
        'file-creator'
    ]);
    grunt.registerTask('publish', ['gh-pages:local']);
    grunt.registerTask('default', ['build']);

};<|endoftext|>


<commit_before>'use strict';

const SSM = require( './ssm' );

let input = '';

process.stdin.setEncoding( 'utf8' );

process.stdin.on( 'readable', () => {

    let chunk = process.stdin.read();

    if( chunk ) {

        input+= chunk;
    }
});

process.stdin.on( 'end', () => {

    try {

        let query = JSON.parse( input );

        return new SSM().getParameters( query )
            .then( (parameters) => {

                console.log( JSON.stringify( { success: true, result: { parameters } } ) );
                process.exit( 0 );
            })
            .catch( (error) => {

                let resultObj = { success: false, err: { message: error.message, message: error.stacktrace } };

                console.log( JSON.stringify( resultObj ) );
                process.exit( 1 );

            });
    }
    catch( err ) {

        let resultObj = { success: false, err: { message: err.message, message: err.stacktrace } };

        console.log( JSON.stringify( resultObj ) );
        process.exit( 1 );
    }
});
<commit_msg>cleaned up code<commit_after>'use strict';

const SSM = require( './ssm' );

function handleError( err ) {

    let resultObj = { success: false, err };

    console.log( JSON.stringify( resultObj ) );
    process.exit( 1 );
}

let input = '';

process.stdin.setEncoding( 'utf8' );

process.stdin.on( 'readable', () => {

    let chunk = process.stdin.read();

    if( chunk ) {

        input+= chunk;
    }
});

process.stdin.on( 'end', () => {

    try {

        let query = JSON.parse( input );

        return new SSM().getParameters( query )
            .then( (parameters) => {

                console.log( JSON.stringify( { success: true, result: { parameters } } ) );
                process.exit( 0 );
            })
            .catch( handleError );
    }
    catch( err ) {

        handleError( err );
    }
});
<|endoftext|>


<commit_before>module.exports = function(grunt) {

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-gh-pages');

    grunt.initConfig({
        'gh-pages': {
            options: {
                branch: 'gh-pages'
            },
            publish: {
                repo: 'https://github.com/ahennr/SolrHeatmap.git',
                message: 'Publish gh-pages (grunt cli)',
                src: '**/*'
            },
            deploy: {
                options: {
                    user: {
                        name: 'ahennr',
                        email: 'henn@terrestris.de'
                    },
                    repo: 'https://' + process.env.GH_TOKEN + '@github.com/terrestris/SolrHeatmap.git',
                    message: 'Publish gh-pages (auto)' + getDeployMessage(),
                    silent: true
                },
                src: '**/*'
            }
        }
    });

    // get a formatted commit message to review changes from the commit log
    // github will turn some of these into clickable links
    function getDeployMessage() {
        var ret = '\n\n';
        if (process.env.TRAVIS !== 'true') {
            ret += 'missing env vars for travis-ci';
            return ret;
        }
        ret += 'branch:       ' + process.env.TRAVIS_BRANCH + '\n';
        ret += 'SHA:          ' + process.env.TRAVIS_COMMIT + '\n';
        ret += 'range SHA:    ' + process.env.TRAVIS_COMMIT_RANGE + '\n';
        ret += 'build id:     ' + process.env.TRAVIS_BUILD_ID + '\n';
        ret += 'build number: ' + process.env.TRAVIS_BUILD_NUMBER + '\n';
        return ret;
    }

    grunt.registerTask('check-deploy', function() {
        // only deploy under these conditions
        if (process.env.TRAVIS === 'true' && process.env.TRAVIS_SECURE_ENV_VARS === 'true' && process.env.TRAVIS_PULL_REQUEST === 'false') {
            grunt.log.writeln('executing deployment');
            // queue deploy
            grunt.task.run('gh-pages:deploy');
        } else {
            grunt.log.writeln('skipped deployment');
        }
    });

    grunt.registerTask('publish', 'Publish from CLI', [
        'gh-pages:publish'
    ]);

    grunt.registerTask('deploy', 'Publish from travis', [
        'check-deploy'
    ]);

};
<commit_msg>spcify sources which should be published to gh-pages<commit_after>module.exports = function(grunt) {

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-gh-pages');

    grunt.initConfig({
        'gh-pages': {
            options: {
                branch: 'gh-pages'
            },
            publish: {
                repo: 'https://github.com/ahennr/SolrHeatmap.git',
                message: 'Publish gh-pages (grunt cli)',
                src: ['index.html', 'app/**', 'assets/**', 'config/**', 'LICENSE']
            },
            deploy: {
                options: {
                    user: {
                        name: 'ahennr',
                        email: 'henn@terrestris.de'
                    },
                    repo: 'https://' + process.env.GH_TOKEN + '@github.com/terrestris/SolrHeatmap.git',
                    message: 'Publish gh-pages (auto)' + getDeployMessage(),
                    silent: true
                },
                src: ['index.html', 'app/**', 'assets/**', 'config/**', 'LICENSE']
            }
        }
    });

    // get a formatted commit message to review changes from the commit log
    // github will turn some of these into clickable links
    function getDeployMessage() {
        var ret = '\n\n';
        if (process.env.TRAVIS !== 'true') {
            ret += 'missing env vars for travis-ci';
            return ret;
        }
        ret += 'branch:       ' + process.env.TRAVIS_BRANCH + '\n';
        ret += 'SHA:          ' + process.env.TRAVIS_COMMIT + '\n';
        ret += 'range SHA:    ' + process.env.TRAVIS_COMMIT_RANGE + '\n';
        ret += 'build id:     ' + process.env.TRAVIS_BUILD_ID + '\n';
        ret += 'build number: ' + process.env.TRAVIS_BUILD_NUMBER + '\n';
        return ret;
    }

    grunt.registerTask('check-deploy', function() {
        // only deploy under these conditions
        if (process.env.TRAVIS === 'true' && process.env.TRAVIS_SECURE_ENV_VARS === 'true' && process.env.TRAVIS_PULL_REQUEST === 'false') {
            grunt.log.writeln('executing deployment');
            // queue deploy
            grunt.task.run('gh-pages:deploy');
        } else {
            grunt.log.writeln('skipped deployment');
        }
    });

    grunt.registerTask('publish', 'Publish from CLI', [
        'gh-pages:publish'
    ]);

    grunt.registerTask('deploy', 'Publish from travis', [
        'check-deploy'
    ]);

};
<|endoftext|>


<commit_before>/**
 * @flow
 * @Author: Wahaj Shamim <wahaj>
 * @Date:   2018-02-15T15:05:45+11:00
 * @Email:  inbox.wahaj@gmail.com
 * @Last modified by:   mike
 * @Last modified time: 2018-02-19T14:55:25+11:00
 *
 * dbKoda - a modern, open source code editor, for MongoDB.
 * Copyright (C) 2017-2018 Southbank Software
 *
 * This file is part of dbKoda.
 *
 * dbKoda is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * dbKoda is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with dbKoda.  If not, see <http://www.gnu.org/licenses/>.
 */

import _ from 'lodash';

function timescale(num: number, a, b) {
  if (isNaN(num)) {
    throw new TypeError('expected a number');
  }
  if (unitTimeValue(a) > unitTimeValue(b)) {
    return num / (unitTimeValue(a) / unitTimeValue(b));
  }
  return num * unitTimeValue(a) / unitTimeValue(b);
}

function unitTimeValue(name) {
  switch (name) {
    case 'ns':
      return 1;
    case 'μs':
    case 'us':
      return 1e3;
    case 'ms':
      return 1e6;
    case 's':
      return 1e9;
    case 'm':
      return 6e10;
    case 'h':
      return 36e11;
    case 'd':
      return 864e11;
    case 'w':
      return 6048e11;
    default: {
      throw new Error('"' + name + '" is not a valid unit of time.');
    }
  }
}
export const convertTime = (value: any, unit: string, length: number) => {
  const result = {
    value,
    unit
  };
  if (String(Math.round(value)).length > length) {
    switch (unit) {
      case '/μs':
        result.unit = '/ms';
        result.value = timescale(value, 'μs', 'ms').toFixed(2);
        break;
      case '/ms':
        result.unit = '/s';
        result.value = timescale(value, 'ms', 's').toFixed(2);
        break;
      case '/s':
        result.unit = 'k/s';
        result.value /= 1000;
        break;
      case 'k/s':
        result.unit = 'M/s';
        result.value /= 1000;
        break;
      case 'μs/s':
        result.unit = 'ms/s';
        result.value = timescale(value, 'μs', 'ms').toFixed(2);
        break;
      case 'ms/s':
        result.unit = 's/s';
        result.value = timescale(value, 'ms', 's').toFixed(2);
        break;
      case 'Op/s':
        result.unit = 'KOp/s';
        result.value /= 1000;
        break;
      case 'KOp/ss':
        result.unit = 'MOp/μs';
        result.value /= 1000;
        break;
      case 'pages/s':
        result.unit = 'Kpages/s';
        result.value /= 1000;
        break;
      case 'Kpages/s':
        result.unit = 'Mpages/s';
        result.value /= 1000;
        break;
      case 'μs':
        result.unit = 'ms';
        result.value = timescale(value, 'μs', 'ms').toFixed(2);
        break;
      case 'ms':
        result.unit = 's';
        result.value = timescale(value, 'ms', 's').toFixed(2);
        break;
      case ' ':
        result.unit = 'k';
        result.value /= 1000;
        break;
      case 'k':
        result.unit = 'M';
        result.value /= 1000;
        break;
      default: {
        console.error('"' + unit + '" is not a valid unit of time.');
        return result;
      }
    }
    return convertTime(result.value, result.unit, length);
  }
  result.value = parseFloat(Number(value).toFixed(2));
  return result;
};

export const convertBytes = (value: any, unit: string, length: number) => {
  const result = {
    value,
    unit
  };
  if (String(Math.round(value)).length > length) {
    switch (unit) {
      case 'b':
        result.unit = 'kb';
        break;
      case 'kb':
        result.unit = 'mb';
        break;
      case 'mb':
        result.unit = 'gb';
        break;
      case 'gb':
        result.unit = 'tb';
        break;
      case 'tb':
        result.unit = 'pb';
        break;
      case 'pb':
        result.unit = 'eb';
        break;
      case 'b/s':
        result.unit = 'kb/s';
        break;
      case 'kb/s':
        result.unit = 'mb/s';
        break;
      case 'mb/s':
        result.unit = 'gb/s';
        break;
      case 'gb/s':
        result.unit = 'tb/s';
        break;
      default: {
        console.error('"' + unit + '" is the maximum supported unit of bytes.');
        return result;
      }
    }
    result.value = (value / 1024).toFixed(2);
    return convertBytes(result.value, result.unit, length);
  }
  result.value = value.toFixed(2);
  return result;
};

export const convertUnits = (value: any, unit: string, length: number) => {
  if (
    's|ms|μs|ms/s|μs/s|/μs|/us|/ms|/s|/m|/h|Op/s|KOp/s|MOp/s|pages/s|Kpages/s|Mpages/s| |k'.indexOf(
      unit
    ) >= 0
  ) {
    return convertTime(value, unit, length);
  } else if ('b|kb|mb|gb|tb|pb|eb|b/s|kb/s|mb/s|gb/s|tb/s'.indexOf(unit) >= 0) {
    return convertBytes(value, unit, length);
  }
  console.log('Unknown unit is provided for conversion (unit=', unit, ').');
  return {
    value: parseFloat(Number(value).toFixed(2)),
    unit
  };
};

export const hofUnitFormatter = (unit: string, length: number) => {
  // $FlowFixMe
  const unitFormatter = value => {
    const result = convertUnits(value, unit, length);
    return result.value + ' ' + result.unit;
  };
  return unitFormatter;
};

export const bytesToSize = (bytes: number) => {
  const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
  if (bytes <= 0) return '0 B';
  const i = _.round(
    parseFloat(Math.floor(Math.log(bytes) / Math.log(1024))),
    2
  );
  if (i < 0) {
    return '0B';
  }
  return _.round(bytes / 1024 ** i, 1) + '' + sizes[i];
};
<commit_msg>Fixed unit conversion bug due to some values being string and some being numbers.<commit_after>/**
 * @flow
 * @Author: Wahaj Shamim <wahaj>
 * @Date:   2018-02-15T15:05:45+11:00
 * @Email:  inbox.wahaj@gmail.com
 * @Last modified by:   mike
 * @Last modified time: 2018-02-19T14:55:25+11:00
 *
 * dbKoda - a modern, open source code editor, for MongoDB.
 * Copyright (C) 2017-2018 Southbank Software
 *
 * This file is part of dbKoda.
 *
 * dbKoda is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * dbKoda is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with dbKoda.  If not, see <http://www.gnu.org/licenses/>.
 */

import _ from 'lodash';

function timescale(num: number, a, b) {
  if (isNaN(num)) {
    throw new TypeError('expected a number');
  }
  if (unitTimeValue(a) > unitTimeValue(b)) {
    return num / (unitTimeValue(a) / unitTimeValue(b));
  }
  return num * unitTimeValue(a) / unitTimeValue(b);
}

function unitTimeValue(name) {
  switch (name) {
    case 'ns':
      return 1;
    case 'μs':
    case 'us':
      return 1e3;
    case 'ms':
      return 1e6;
    case 's':
      return 1e9;
    case 'm':
      return 6e10;
    case 'h':
      return 36e11;
    case 'd':
      return 864e11;
    case 'w':
      return 6048e11;
    default: {
      throw new Error('"' + name + '" is not a valid unit of time.');
    }
  }
}
export const convertTime = (value: any, unit: string, length: number) => {
  const result = {
    value,
    unit
  };
  if (String(Math.round(value)).length > length) {
    switch (unit) {
      case '/μs':
        result.unit = '/ms';
        result.value = timescale(value, 'μs', 'ms');
        break;
      case '/ms':
        result.unit = '/s';
        result.value = timescale(value, 'ms', 's');
        break;
      case '/s':
        result.unit = 'k/s';
        result.value /= 1000;
        break;
      case 'k/s':
        result.unit = 'M/s';
        result.value /= 1000;
        break;
      case 'μs/s':
        result.unit = 'ms/s';
        result.value = timescale(value, 'μs', 'ms');
        break;
      case 'ms/s':
        result.unit = 's/s';
        result.value = timescale(value, 'ms', 's');
        break;
      case 'Op/s':
        result.unit = 'KOp/s';
        result.value /= 1000;
        break;
      case 'KOp/ss':
        result.unit = 'MOp/μs';
        result.value /= 1000;
        break;
      case 'pages/s':
        result.unit = 'Kpages/s';
        result.value /= 1000;
        break;
      case 'Kpages/s':
        result.unit = 'Mpages/s';
        result.value /= 1000;
        break;
      case 'μs':
        result.unit = 'ms';
        result.value = timescale(value, 'μs', 'ms');
        break;
      case 'ms':
        result.unit = 's';
        result.value = timescale(value, 'ms', 's');
        break;
      case ' ':
        result.unit = 'k';
        result.value /= 1000;
        break;
      case 'k':
        result.unit = 'M';
        result.value /= 1000;
        break;
      default: {
        console.error('"' + unit + '" is not a valid unit of time.');
        return result;
      }
    }
    return convertTime(result.value, result.unit, length);
  }
  result.value = _.round(parseFloat(Number(value)), 2);
  return result;
};

export const convertBytes = (value: any, unit: string, length: number) => {
  const result = {
    value,
    unit
  };
  if (String(Math.round(value)).length > length) {
    switch (unit) {
      case 'b':
        result.unit = 'kb';
        break;
      case 'kb':
        result.unit = 'mb';
        break;
      case 'mb':
        result.unit = 'gb';
        break;
      case 'gb':
        result.unit = 'tb';
        break;
      case 'tb':
        result.unit = 'pb';
        break;
      case 'pb':
        result.unit = 'eb';
        break;
      case 'b/s':
        result.unit = 'kb/s';
        break;
      case 'kb/s':
        result.unit = 'mb/s';
        break;
      case 'mb/s':
        result.unit = 'gb/s';
        break;
      case 'gb/s':
        result.unit = 'tb/s';
        break;
      default: {
        console.error('"' + unit + '" is the maximum supported unit of bytes.');
        return result;
      }
    }

    result.value = parseFloat(value) / 1024;
    return convertBytes(result.value, result.unit, length);
  }
  result.value = _.round(parseFloat(value), 2);
  return result;
};

export const convertUnits = (value: any, unit: string, length: number) => {
  if (
    's|ms|μs|ms/s|μs/s|/μs|/us|/ms|/s|/m|/h|Op/s|KOp/s|MOp/s|pages/s|Kpages/s|Mpages/s| |k'.indexOf(
      unit
    ) >= 0
  ) {
    return convertTime(value, unit, length);
  } else if ('b|kb|mb|gb|tb|pb|eb|b/s|kb/s|mb/s|gb/s|tb/s'.indexOf(unit) >= 0) {
    return convertBytes(value, unit, length);
  }
  console.log('Unknown unit is provided for conversion (unit=', unit, ').');
  return {
    value: parseFloat(_.round(Number(value), 2)),
    unit
  };
};

export const hofUnitFormatter = (unit: string, length: number) => {
  // $FlowFixMe
  const unitFormatter = value => {
    const result = convertUnits(value, unit, length);
    return result.value + ' ' + result.unit;
  };
  return unitFormatter;
};

export const bytesToSize = (bytes: number) => {
  const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
  if (bytes <= 0) return '0 B';
  const i = _.round(
    parseFloat(Math.floor(Math.log(bytes) / Math.log(1024))),
    2
  );
  if (i < 0) {
    return '0B';
  }
  return _.round(bytes / 1024 ** i, 1) + '' + sizes[i];
};
<|endoftext|>


<commit_before>/* jshint node: true */

'use strict';

module.exports =
    function (grunt)
    {
        var JS_FILES =
            {
                default: ['*.js', 'build/**/*.js', 'src/**/*.js', 'test/**/*.js'],
                html: 'src/html/**/*.js',
                lib: ['src/lib/**/*.js', 'test/**/*.js']
            };

        // Project configuration.
        grunt.initConfig(
            {
                clean:
                {
                    build: ['Features.md', 'output.txt'],
                    html: 'html/**/*.js',
                    lib: ['coverage', 'lib/**/*.js']
                },
                concat:
                {
                    lib:
                    {
                        src:
                        [
                            'src/lib/preamble',
                            'src/lib/features.js',
                            'src/lib/definers.js',
                            'src/lib/definitions.js',
                            'src/lib/screw-buffer.js',
                            'src/lib/encoder.js',
                            'src/lib/trim-js.js',
                            'src/lib/jscrewit-base.js',
                            'src/lib/debug.js',
                            'src/lib/postamble'
                        ],
                        dest: 'lib/jscrewit.js'
                    },
                    options:
                    {
                        banner: '//! JScrewIt <%= pkg.version %> – <%= pkg.homepage %>\n',
                        separator: '\n',
                        stripBanners: true
                    }
                },
                jscs:
                {
                    default: JS_FILES.default,
                    html: JS_FILES.html,
                    lib: JS_FILES.lib,
                    options:
                    {
                        // Encourage use of abbreviations: "char", "obj", "str".
                        disallowIdentifierNames: ['character', 'object', 'string'],
                        disallowMixedSpacesAndTabs: true,
                        disallowSpaceAfterObjectKeys: true,
                        disallowSpaceAfterPrefixUnaryOperators: true,
                        disallowSpaceBeforePostfixUnaryOperators: true,
                        disallowSpacesInCallExpression: true,
                        disallowSpacesInFunctionDeclaration: { beforeOpeningRoundBrace: true },
                        disallowSpacesInNamedFunctionExpression: { beforeOpeningRoundBrace: true },
                        disallowSpacesInsideBrackets: true,
                        disallowSpacesInsideParentheses: true,
                        disallowTrailingWhitespace: 'ignoreEmptyLines',
                        disallowYodaConditions: true,
                        requireBlocksOnNewline: 1,
                        requireKeywordsOnNewLine:
                        [
                            'break',
                            'case',
                            'catch',
                            'continue',
                            'default',
                            'do',
                            'else',
                            'finally',
                            'for',
                            'switch',
                            'throw',
                            'try'
                        ],
                        requireLineBreakAfterVariableAssignment: true,
                        requireLineFeedAtFileEnd: true,
                        requirePaddingNewLinesAfterUseStrict: true,
                        requireSpaceAfterBinaryOperators: true,
                        requireSpaceAfterKeywords: true,
                        requireSpaceAfterLineComment: true,
                        requireSpaceBeforeBinaryOperators: true,
                        requireSpaceBeforeBlockStatements: true,
                        requireSpaceBeforeKeywords:
                        [
                            'delete',
                            'if',
                            'in',
                            'instanceof',
                            'return',
                            'while'
                        ],
                        requireSpaceBeforeObjectValues: true,
                        requireSpaceBetweenArguments: true,
                        requireSpacesInAnonymousFunctionExpression:
                        {
                            beforeOpeningRoundBrace: true
                        },
                        requireSpacesInConditionalExpression: true,
                        requireSpacesInForStatement: true,
                        requireSpacesInFunctionDeclaration: { beforeOpeningCurlyBrace: true },
                        requireSpacesInFunctionExpression: { beforeOpeningCurlyBrace: true },
                        requireSpacesInsideObjectBrackets: 'all',
                        validateAlignedFunctionParameters: true,
                        validateIndentation: 4,
                        validateParameterSeparator: ', '
                    }
                },
                jshint:
                {
                    default: JS_FILES.default,
                    html: JS_FILES.html,
                    lib: JS_FILES.lib,
                    options:
                    {
                        curly: true,
                        eqeqeq: true,
                        immed: true,
                        latedef: 'nofunc',
                        maxlen: 100,
                        newcap: false,
                        noarg: true,
                        noempty: true,
                        quotmark: true,
                        singleGroups: true,
                        strict: true,
                        trailing: true,
                        undef: true,
                        unused: true,

                        boss: true,
                        elision: true,
                        eqnull: true,
                        evil: true,
                        validthis: true,
                        '-W018': true,
                    }
                },
                mocha_istanbul:
                {
                    default: 'test/**/*.spec.js',
                    lib: { options: { root: 'lib' }, src: 'test/**/jscrewit.spec.js' }
                },
                pkg: grunt.file.readJSON('package.json'),
                uglify:
                {
                    html:
                    {
                        files:
                        {
                            'html/ui.js':
                            [
                                'src/html/art.js',
                                'src/html/engine-selection-box.js',
                                'src/html/roll.js',
                                'src/html/ui-main.js'
                            ],
                            'html/worker.js': 'src/html/worker.js'
                        }
                    },
                    lib: { files: { 'lib/jscrewit.min.js': 'lib/jscrewit.js' } },
                    options:
                    {
                        compress: { global_defs: { DEBUG: false }, hoist_vars: true },
                        preserveComments: 'some'
                    }
                }
            }
        );

        // These plugins provide necessary tasks.
        grunt.loadNpmTasks('grunt-contrib-clean');
        grunt.loadNpmTasks('grunt-contrib-concat');
        grunt.loadNpmTasks('grunt-contrib-jshint');
        grunt.loadNpmTasks('grunt-contrib-uglify');
        grunt.loadNpmTasks('grunt-jscs');
        grunt.loadNpmTasks('grunt-mocha-istanbul');

        grunt.registerTask(
            'feature-doc',
            'Create Feature Reference documentation.',
            function ()
            {
                grunt.file.write('Features.md', require('./build/make-feature-doc.js')());
                grunt.log.ok('Done.');
            }
        );

        grunt.registerTask(
            'scan-char-defs',
            'Analyze all character encodings.',
            function ()
            {
                var runScan = require('./build/scan-char-defs.js');
                var unusedDefs = runScan();
                if (unusedDefs)
                {
                    grunt.warn(
                        'There are unused character definitions. See output.txt for details.'
                    );
                }
                else
                {
                    grunt.log.ok('Done. All character definitions used.');
                }
            }
        );

        // Default task.
        grunt.registerTask(
            'default',
            [
                'clean',
                'jshint:default',
                'jscs:default',
                'concat',
                'mocha_istanbul:default',
                'scan-char-defs',
                'uglify',
                'feature-doc'
            ]
        );

        grunt.registerTask(
            'html', ['clean:html', 'jshint:html', 'jscs:html', 'uglify:html']
        );

        grunt.registerTask(
            'lib',
            ['clean:lib', 'jshint:lib', 'jscs:lib', 'concat', 'mocha_istanbul:lib', 'uglify:lib']
        );

        grunt.util.linefeed = '\n';
    };
<commit_msg>Removed unnecessary code from Gruntfile.js<commit_after>/* jshint node: true */

'use strict';

module.exports =
    function (grunt)
    {
        var JS_FILES =
            {
                default: ['*.js', 'build/**/*.js', 'src/**/*.js', 'test/**/*.js'],
                html: 'src/html/**/*.js',
                lib: ['src/lib/**/*.js', 'test/**/*.js']
            };

        // Project configuration.
        grunt.initConfig(
            {
                clean:
                {
                    build: ['Features.md', 'output.txt'],
                    html: 'html/**/*.js',
                    lib: ['coverage', 'lib/**/*.js']
                },
                concat:
                {
                    lib:
                    {
                        src:
                        [
                            'src/lib/preamble',
                            'src/lib/features.js',
                            'src/lib/definers.js',
                            'src/lib/definitions.js',
                            'src/lib/screw-buffer.js',
                            'src/lib/encoder.js',
                            'src/lib/trim-js.js',
                            'src/lib/jscrewit-base.js',
                            'src/lib/debug.js',
                            'src/lib/postamble'
                        ],
                        dest: 'lib/jscrewit.js'
                    },
                    options:
                    {
                        banner: '//! JScrewIt <%= pkg.version %> – <%= pkg.homepage %>\n',
                        stripBanners: true
                    }
                },
                jscs:
                {
                    default: JS_FILES.default,
                    html: JS_FILES.html,
                    lib: JS_FILES.lib,
                    options:
                    {
                        // Encourage use of abbreviations: "char", "obj", "str".
                        disallowIdentifierNames: ['character', 'object', 'string'],
                        disallowMixedSpacesAndTabs: true,
                        disallowSpaceAfterObjectKeys: true,
                        disallowSpaceAfterPrefixUnaryOperators: true,
                        disallowSpaceBeforePostfixUnaryOperators: true,
                        disallowSpacesInCallExpression: true,
                        disallowSpacesInFunctionDeclaration: { beforeOpeningRoundBrace: true },
                        disallowSpacesInNamedFunctionExpression: { beforeOpeningRoundBrace: true },
                        disallowSpacesInsideBrackets: true,
                        disallowSpacesInsideParentheses: true,
                        disallowTrailingWhitespace: 'ignoreEmptyLines',
                        disallowYodaConditions: true,
                        requireBlocksOnNewline: 1,
                        requireKeywordsOnNewLine:
                        [
                            'break',
                            'case',
                            'catch',
                            'continue',
                            'default',
                            'do',
                            'else',
                            'finally',
                            'for',
                            'switch',
                            'throw',
                            'try'
                        ],
                        requireLineBreakAfterVariableAssignment: true,
                        requireLineFeedAtFileEnd: true,
                        requirePaddingNewLinesAfterUseStrict: true,
                        requireSpaceAfterBinaryOperators: true,
                        requireSpaceAfterKeywords: true,
                        requireSpaceAfterLineComment: true,
                        requireSpaceBeforeBinaryOperators: true,
                        requireSpaceBeforeBlockStatements: true,
                        requireSpaceBeforeKeywords:
                        [
                            'delete',
                            'if',
                            'in',
                            'instanceof',
                            'return',
                            'while'
                        ],
                        requireSpaceBeforeObjectValues: true,
                        requireSpaceBetweenArguments: true,
                        requireSpacesInAnonymousFunctionExpression:
                        {
                            beforeOpeningRoundBrace: true
                        },
                        requireSpacesInConditionalExpression: true,
                        requireSpacesInForStatement: true,
                        requireSpacesInFunctionDeclaration: { beforeOpeningCurlyBrace: true },
                        requireSpacesInFunctionExpression: { beforeOpeningCurlyBrace: true },
                        requireSpacesInsideObjectBrackets: 'all',
                        validateAlignedFunctionParameters: true,
                        validateIndentation: 4,
                        validateParameterSeparator: ', '
                    }
                },
                jshint:
                {
                    default: JS_FILES.default,
                    html: JS_FILES.html,
                    lib: JS_FILES.lib,
                    options:
                    {
                        curly: true,
                        eqeqeq: true,
                        immed: true,
                        latedef: 'nofunc',
                        maxlen: 100,
                        newcap: false,
                        noarg: true,
                        noempty: true,
                        quotmark: true,
                        singleGroups: true,
                        strict: true,
                        trailing: true,
                        undef: true,
                        unused: true,

                        boss: true,
                        elision: true,
                        eqnull: true,
                        evil: true,
                        validthis: true,
                        '-W018': true,
                    }
                },
                mocha_istanbul:
                {
                    default: 'test/**/*.spec.js',
                    lib: { options: { root: 'lib' }, src: 'test/**/jscrewit.spec.js' }
                },
                pkg: grunt.file.readJSON('package.json'),
                uglify:
                {
                    html:
                    {
                        files:
                        {
                            'html/ui.js':
                            [
                                'src/html/art.js',
                                'src/html/engine-selection-box.js',
                                'src/html/roll.js',
                                'src/html/ui-main.js'
                            ],
                            'html/worker.js': 'src/html/worker.js'
                        }
                    },
                    lib: { files: { 'lib/jscrewit.min.js': 'lib/jscrewit.js' } },
                    options:
                    {
                        compress: { global_defs: { DEBUG: false }, hoist_vars: true },
                        preserveComments: 'some'
                    }
                }
            }
        );

        // These plugins provide necessary tasks.
        grunt.loadNpmTasks('grunt-contrib-clean');
        grunt.loadNpmTasks('grunt-contrib-concat');
        grunt.loadNpmTasks('grunt-contrib-jshint');
        grunt.loadNpmTasks('grunt-contrib-uglify');
        grunt.loadNpmTasks('grunt-jscs');
        grunt.loadNpmTasks('grunt-mocha-istanbul');

        grunt.registerTask(
            'feature-doc',
            'Create Feature Reference documentation.',
            function ()
            {
                grunt.file.write('Features.md', require('./build/make-feature-doc.js')());
                grunt.log.ok('Done.');
            }
        );

        grunt.registerTask(
            'scan-char-defs',
            'Analyze all character encodings.',
            function ()
            {
                var runScan = require('./build/scan-char-defs.js');
                var unusedDefs = runScan();
                if (unusedDefs)
                {
                    grunt.warn(
                        'There are unused character definitions. See output.txt for details.'
                    );
                }
                else
                {
                    grunt.log.ok('Done. All character definitions used.');
                }
            }
        );

        // Default task.
        grunt.registerTask(
            'default',
            [
                'clean',
                'jshint:default',
                'jscs:default',
                'concat',
                'mocha_istanbul:default',
                'scan-char-defs',
                'uglify',
                'feature-doc'
            ]
        );

        grunt.registerTask(
            'html', ['clean:html', 'jshint:html', 'jscs:html', 'uglify:html']
        );

        grunt.registerTask(
            'lib',
            ['clean:lib', 'jshint:lib', 'jscs:lib', 'concat', 'mocha_istanbul:lib', 'uglify:lib']
        );

        grunt.util.linefeed = '\n';
    };
<|endoftext|>


<commit_before>module.exports = function (grunt) {

	grunt.initConfig({
		jst: {
	            compile: {
	                options: {
	                    namespace: 'TFT',
	                    processName: function (filepath) {
	                        return filepath.replace(/(app\/public\/js\/templates\/|\.tpl)/ig, '');
	                    }
	                },
	                files: {
	                    'app/public/js/templates/templates.js': 'app/public/js/templates/*.tpl'
	                }
	            }
	        },
	        browserify: {
	        	app: {
	        		src: 'app/public/js/main.js',
	        		dest: 'app/public/js/main.bundled.js'
	        	}
	        }
	});
	grunt.loadNpmTasks('grunt-contrib-jst');
	grunt.loadNpmTasks('grunt-browserify');
	grunt.registerTask('default', ['jst', 'browserify']);
};
<commit_msg>lint grunt config<commit_after>module.exports = function (grunt) {

  grunt.initConfig({
    jst: {
      compile: {
        options: {
          namespace: 'TFT',
          processName: function (filepath) {
            return filepath.replace(/(public\/js\/templates\/|\.tpl)/ig, '');
          }
        },
        files: {
          'public/js/templates/templates.js': 'public/js/templates/*.tpl'
        }
      }
    },
    browserify: {
      app: {
        src: 'public/js/main.js',
        dest: 'public/js/main.bundled.js'
      }
    }
  });
ß
  grunt.loadNpmTasks('grunt-contrib-jst');
  grunt.loadNpmTasks('grunt-browserify');
  grunt.registerTask('default', ['jst', 'browserify']);
};
<|endoftext|>


<commit_before>module.exports = function (grunt) {

    var browsers = [
        // chrome
        {
            browserName: "chrome",
            platform: "Windows XP",
            version: "26.0"
        }, {
            browserName: "chrome",
            platform: "OS X 10.9",
            version: "38.0"
        }, {
            browserName: "chrome",
            platform: "Windows 8.1",
            version: "40.0"
        }, {
            browserName: "chrome",
            platform: "Linux",
            version: "30.0"
        },
        // firefox
        {
            browserName: "firefox",
            platform: "Windows 8.1",
            version: "3.6"
        }, {
            browserName: "firefox",
            platform: "Windows XP",
            version: "10.0"
        }, {
            browserName: "firefox",
            platform: "Windows 7",
            version: "17.0"
        }, {
            browserName: "firefox",
            platform: "Linux",
            version: "35.0"
        },
        // internet explorer
        {
            browserName: "internet explorer",
            platform: "Windows XP",
            version: "8.0"
        }, {
            browserName: "internet explorer",
            platform: "Windows 7",
            version: "9.0"
        }, {
            browserName: "internet explorer",
            platform: "Windows 8",
            version: "10.0"
        }, {
            browserName: "internet explorer",
            platform: "Windows 8.1",
            version: "11.0"
        },
        // opera
        {
            browserName: "opera",
            platform: "Windows 7",
            version: "11"
        }, {
            browserName: "opera",
            platform: "Linux",
            version: "12"
        // safari
        }, {
            browserName: "safari",
            platform: "Windows 7",
            version: "5.1"
        }, {
            browserName: "safari",
            platform: "OS X 10.8",
            version: "6.0"
        },
        // apple
        {
            browserName: "iphone",
            platform: "OS X 10.10",
            deviceName: "iPhone Simulator",
            "device-orientation": "portrait",
            version: "6.1"
        }, {
            browserName: "iphone",
            platform: "OS X 10.10",
            deviceName: "iPad Simulator",
            "device-orientation": "portrait",
            version: "6.0"
        }, {
            browserName: "iphone",
            platform: "OS X 10.10",
            deviceName: "iPhone Simulator",
            "device-orientation": "portrait",
            version: "7.1"
        }, {
            browserName: "iphone",
            platform: "OS X 10.10",
            deviceName: "iPhone Simulator",
            "device-orientation": "portrait",
            version: "8.1"
        },
        // android
        {
            browserName: "android",
            platform: "Linux",
            deviceName: "Samsung Galaxy S2 Emulator",
            version: "4.2"
        }, {
            browserName: "android",
            platform: "Linux",
            deviceName: "Motorola Droid Razr Emulator",
            version: "4.0"
        }, {
            browserName: "android",
            platform: "Linux",
            deviceName: "Samsung Galaxy S3 Emulator",
            version: "4.1"
        }];

    grunt.initConfig({
        uglify: {
            target: {
                files: {
                    'src/justlazy.min.js': ['src/justlazy.js']
                }
            }
        },
        jshint: {
            files: [
                "Gruntfile.js",
                "src/justlazy.js",
                "spec/**/*.js"
            ]
        },
        jasmine: {
            src: "src/**/*.js",
            options: {
                vendor: [
                    "jasmine-standalone/lib/jasmine-jquery-2.0.7/jquery.js",
                    "jasmine-standalone/lib/jasmine-jquery-2.0.7/jasmine-jquery.js",
                    "jasmine-standalone/phantomjs-config.js"
                ],
                specs: "spec/**/*.js"
            }
        },
        connect: {
            server: {
                options: {
                    base: "",
                    port: 9999
                }
            }
        },
        "saucelabs-jasmine": {
            all: {
                options: {
                    urls: ["http://127.0.0.1:9999/jasmine-standalone/SpecRunner.html"],
                    build: process.env.TRAVIS_JOB_ID,
                    browsers: browsers,
                    testname: "justlazy.js tests",
                    "max-duration": 240,
                    tags: ["master"]
                }
            }
        },
        watch: {}
    });

    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-jasmine");
    grunt.loadNpmTasks("grunt-saucelabs");
    grunt.loadNpmTasks("grunt-contrib-connect");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks('grunt-contrib-uglify');

    grunt.registerTask("server", ["connect", "watch"]);
    grunt.registerTask("minify", ["uglify"]);
    grunt.registerTask("test-jshint", ["jshint"]);
    grunt.registerTask("test-jasmine", ["jasmine"]);
    grunt.registerTask("test-browsers", ["connect", "saucelabs-jasmine"]);
    grunt.registerTask("test-all", ["jshint", "jasmine", "connect", "saucelabs-jasmine"]);
    grunt.registerTask("travis-ci", ["test-all"]);

    grunt.registerTask("default", ["test-jshint", "test-jasmine", "minify"]);

};
<commit_msg>remove ff 3.6 saucelabs test because the browser doesnt support the jasmine test suite<commit_after>module.exports = function (grunt) {

    var browsers = [
        // chrome
        {
            browserName: "chrome",
            platform: "Windows XP",
            version: "26.0"
        }, {
            browserName: "chrome",
            platform: "OS X 10.9",
            version: "38.0"
        }, {
            browserName: "chrome",
            platform: "Windows 8.1",
            version: "40.0"
        }, {
            browserName: "chrome",
            platform: "Linux",
            version: "30.0"
        },
        // firefox
        {
            browserName: "firefox",
            platform: "Windows XP",
            version: "10.0"
        }, {
            browserName: "firefox",
            platform: "Windows 7",
            version: "17.0"
        }, {
            browserName: "firefox",
            platform: "Linux",
            version: "35.0"
        },
        // internet explorer
        {
            browserName: "internet explorer",
            platform: "Windows XP",
            version: "8.0"
        }, {
            browserName: "internet explorer",
            platform: "Windows 7",
            version: "9.0"
        }, {
            browserName: "internet explorer",
            platform: "Windows 8",
            version: "10.0"
        }, {
            browserName: "internet explorer",
            platform: "Windows 8.1",
            version: "11.0"
        },
        // opera
        {
            browserName: "opera",
            platform: "Windows 7",
            version: "11"
        }, {
            browserName: "opera",
            platform: "Linux",
            version: "12"
        // safari
        }, {
            browserName: "safari",
            platform: "Windows 7",
            version: "5.1"
        }, {
            browserName: "safari",
            platform: "OS X 10.8",
            version: "6.0"
        },
        // apple
        {
            browserName: "iphone",
            platform: "OS X 10.10",
            deviceName: "iPhone Simulator",
            "device-orientation": "portrait",
            version: "6.1"
        }, {
            browserName: "iphone",
            platform: "OS X 10.10",
            deviceName: "iPad Simulator",
            "device-orientation": "portrait",
            version: "6.0"
        }, {
            browserName: "iphone",
            platform: "OS X 10.10",
            deviceName: "iPhone Simulator",
            "device-orientation": "portrait",
            version: "7.1"
        }, {
            browserName: "iphone",
            platform: "OS X 10.10",
            deviceName: "iPhone Simulator",
            "device-orientation": "portrait",
            version: "8.1"
        },
        // android
        {
            browserName: "android",
            platform: "Linux",
            deviceName: "Samsung Galaxy S2 Emulator",
            version: "4.2"
        }, {
            browserName: "android",
            platform: "Linux",
            deviceName: "Motorola Droid Razr Emulator",
            version: "4.0"
        }, {
            browserName: "android",
            platform: "Linux",
            deviceName: "Samsung Galaxy S3 Emulator",
            version: "4.1"
        }];

    grunt.initConfig({
        uglify: {
            target: {
                files: {
                    'src/justlazy.min.js': ['src/justlazy.js']
                }
            }
        },
        jshint: {
            files: [
                "Gruntfile.js",
                "src/justlazy.js",
                "spec/**/*.js"
            ]
        },
        jasmine: {
            src: "src/**/*.js",
            options: {
                vendor: [
                    "jasmine-standalone/lib/jasmine-jquery-2.0.7/jquery.js",
                    "jasmine-standalone/lib/jasmine-jquery-2.0.7/jasmine-jquery.js",
                    "jasmine-standalone/phantomjs-config.js"
                ],
                specs: "spec/**/*.js"
            }
        },
        connect: {
            server: {
                options: {
                    base: "",
                    port: 9999
                }
            }
        },
        "saucelabs-jasmine": {
            all: {
                options: {
                    urls: ["http://127.0.0.1:9999/jasmine-standalone/SpecRunner.html"],
                    build: process.env.TRAVIS_JOB_ID,
                    browsers: browsers,
                    testname: "justlazy.js tests",
                    "max-duration": 240,
                    tags: ["master"]
                }
            }
        },
        watch: {}
    });

    grunt.loadNpmTasks("grunt-contrib-jshint");
    grunt.loadNpmTasks("grunt-contrib-jasmine");
    grunt.loadNpmTasks("grunt-saucelabs");
    grunt.loadNpmTasks("grunt-contrib-connect");
    grunt.loadNpmTasks("grunt-contrib-watch");
    grunt.loadNpmTasks('grunt-contrib-uglify');

    grunt.registerTask("server", ["connect", "watch"]);
    grunt.registerTask("minify", ["uglify"]);
    grunt.registerTask("test-jshint", ["jshint"]);
    grunt.registerTask("test-jasmine", ["jasmine"]);
    grunt.registerTask("test-browsers", ["connect", "saucelabs-jasmine"]);
    grunt.registerTask("test-all", ["jshint", "jasmine", "connect", "saucelabs-jasmine"]);
    grunt.registerTask("travis-ci", ["test-all"]);

    grunt.registerTask("default", ["test-jshint", "test-jasmine", "minify"]);

};
<|endoftext|>


<commit_before>module.exports = function(grunt) {
    // Load grunt plugins
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        // Lint configuration
        jshint: {
          files: ['Gruntfile.js', 'index.js', 'test/index.js'],
          options: {
            jshintrc: '.jshintrc',
          }
        },

        // Test configuration
        mochaTest: {
            test: {
                src: ['test/**/*.js'],
            }
        },

        watch: {
            files: ['Gruntfile.js', 'index.js', 'test/index.js'],
            tasks: ['test']
        }
    });

    // rename the release task so we can use it in our custom task
    grunt.renameTask('release', 'publish');

    grunt.registerTask('release', function(target) {
        if (!target) { target = 'patch'; }
        grunt.task.run(['test', 'publish:'+target]);
    });

    grunt.registerTask('test', ['jshint', 'mochaTest']);

    grunt.registerTask('default', ['watch']);
};
<commit_msg>Better file watching.<commit_after>module.exports = function(grunt) {
    // Load grunt plugins
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        // Lint configuration
        jshint: {
            files: ['*.js', 'test/*.js'],
            // This is slower due to having to exclude all the extra files
            // files: ['**/*.js', '!**/node_modules/**'],
            options: {
                jshintrc: '.jshintrc',
            }
        },

        // Test configuration
        mochaTest: {
            test: {
                src: ['test/**/*.js'],
            }
        },

        watch: {
            files: ['*.js', 'test/*.js'],
            // This is slower due to having to exclude all the extra files
            // files: ['**/*.js', '!**/node_modules/**'],
            tasks: ['test']
        }
    });

    // rename the release task so we can use it in our custom task
    grunt.renameTask('release', 'publish');

    grunt.registerTask('release', function(target) {
        if (!target) { target = 'patch'; }
        grunt.task.run(['test', 'publish:'+target]);
    });

    grunt.registerTask('test', ['jshint', 'mochaTest']);

    grunt.registerTask('default', ['watch']);
};
<|endoftext|>


<commit_before>'use strict';

var conf = require('./files.conf.js');

module.exports = function(grunt) {

    // GRUNT CONFIGURATION
    grunt.initConfig({

        pkg: conf.pkg,

        jshint: {

            files: [
                '*.js',
                'src/**/*.js',
                '*.json',
                '.jshintrc',
                'test/**/*.js'
            ],

            options: {

                jshintrc: '.jshintrc'

            }

        },

        concat: {

            options: {

                stripBanners: true,

                banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n' + '\'use strict\';\n',

                process: function(src, filepath) {
                    return '\n// Source: ' + filepath + '\n' +
                        src.replace(/'use strict';\n/g, '');
                }
            },

            dist: {

                src: conf.stimuliFiles,

                dest: conf.distFolder + '<%= pkg.name %>.js'

            }
        },

        copy: {

            license: {

                src: 'LICENSE',

                dest: conf.distFolder

            },

            readme: {

                src: 'README.md',

                dest: conf.distFolder
            },

            blank: {

                src: 'src/blank.html',

                dest: conf.distFolder + 'blank.html'
            }

        },

        coveralls: {
            options: {
                coverage_dir: 'coverage'
            }
        },

        hub: {

            event_tester: {

              src: ['tools/event_tester/Gruntfile.js'],

              tasks: ['jshint', 'build:templates']

            }
        },

        jsduck: {

            main: {
                // source paths with your code
                src: [
                    'src'
                ],

                // docs output dir
                dest: conf.distFolder + 'docs',

                // extra options
                options: {
                    exclude: [
                        'src/keyboard/layout/macosx',
                        'src/keyboard/layout/linux',
                        'src/keyboard/layout/windows'
                    ],
                    title: "Stimuli <%= pkg.version %> Documentation"
                }
            }
        }

    });

    grunt.registerTask('sizzle', function(){
        var done = this.async();
        grunt.util.spawn({ cmd: 'bower', args: ['install'], opts: {stdio: 'inherit'}}, function() {
            grunt.util.spawn({ cmd: 'rm', args: ['-rf', 'lib'], opts: {stdio: 'inherit'}}, function() {
                grunt.util.spawn({ cmd: 'mv', args: ['bower_components', 'lib'], opts: {stdio: 'inherit'}}, function() {
                    grunt.util.spawn({ cmd: 'mv', args: ['lib/sizzle/dist/sizzle.js', 'lib/sizzle/'], opts: {stdio: 'inherit'}}, done);
                });
            });

        });
    });

    grunt.registerTask('phantom', function(){
        var done = this.async();
        grunt.util.spawn({
            cmd: 'karma',
            args: ['start', 'karma.phantom.conf.js', '--browsers',
                'PhantomJS'],
            opts: {stdio: 'inherit'}
        },done);
    });

    grunt.registerTask('test_coverage', function(){
        var done = this.async();
        grunt.util.spawn({
            cmd: 'karma',
            args: ['start', 'karma.coverage.conf.js', '--browsers',
                'PhantomJS,Firefox,BS_IE10'],
            opts: {stdio: 'inherit'}
        },done);
    });

    grunt.registerTask('test_all', function(){
        var done = this.async();
        grunt.util.spawn({
            cmd: 'karma',
            args: ['start', 'karma.travis.conf.js', '--browsers',
            'BS_IE8,BS_IE9,BS_IE10,BS_IE11,BS_FIREFOX,BS_ANDROID_4,BS_ANDROID_41,BS_ANDROID_42,BS_IOS_6,BS_CHROME,BS_SAFARI51,BS_SAFARI6'
            ],
            opts: {stdio: 'inherit'}
        },done);
    });

    grunt.registerTask('watch', function(){
        var done = this.async();
        grunt.util.spawn({
            cmd: 'karma',
            args: ['start', 'karma.conf.js'],
            opts: {stdio: 'inherit'}
        },done);
    });

    grunt.registerTask('nginx_start', function(){
      var done = this.async();
      grunt.util.spawn({
        cmd: 'nginx',
        args: ['-c', '.nginx/nginx.conf', '-p', '.'],
        opts: {stdio: 'inherit'}
      },done);
    });

    grunt.registerTask('nginx_stop', function(){
      var done = this.async();
      grunt.util.spawn({
        cmd: 'nginx',
        args: ['-c', '.nginx/nginx.conf', '-p', '.', '-s', 'stop'],
        opts: {stdio: 'inherit'}
      },done);
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-jsduck');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-hub');
    grunt.loadNpmTasks('grunt-karma-coveralls');

    grunt.registerTask('build', [ 'sizzle', 'concat:dist', 'jsduck', 'copy']);

    grunt.registerTask('travis', ['jshint', 'build', 'phantom', 'test_coverage', 'coveralls', 'test_all']);

    grunt.registerTask('test_travis_local', ['nginx_start', 'build', 'test_all', 'nginx_stop']);
};<commit_msg>chore(build): remove ie10 from test coverage<commit_after>'use strict';

var conf = require('./files.conf.js');

module.exports = function(grunt) {

    // GRUNT CONFIGURATION
    grunt.initConfig({

        pkg: conf.pkg,

        jshint: {

            files: [
                '*.js',
                'src/**/*.js',
                '*.json',
                '.jshintrc',
                'test/**/*.js'
            ],

            options: {

                jshintrc: '.jshintrc'

            }

        },

        concat: {

            options: {

                stripBanners: true,

                banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n' + '\'use strict\';\n',

                process: function(src, filepath) {
                    return '\n// Source: ' + filepath + '\n' +
                        src.replace(/'use strict';\n/g, '');
                }
            },

            dist: {

                src: conf.stimuliFiles,

                dest: conf.distFolder + '<%= pkg.name %>.js'

            }
        },

        copy: {

            license: {

                src: 'LICENSE',

                dest: conf.distFolder

            },

            readme: {

                src: 'README.md',

                dest: conf.distFolder
            },

            blank: {

                src: 'src/blank.html',

                dest: conf.distFolder + 'blank.html'
            }

        },

        coveralls: {
            options: {
                coverage_dir: 'coverage'
            }
        },

        hub: {

            event_tester: {

              src: ['tools/event_tester/Gruntfile.js'],

              tasks: ['jshint', 'build:templates']

            }
        },

        jsduck: {

            main: {
                // source paths with your code
                src: [
                    'src'
                ],

                // docs output dir
                dest: conf.distFolder + 'docs',

                // extra options
                options: {
                    exclude: [
                        'src/keyboard/layout/macosx',
                        'src/keyboard/layout/linux',
                        'src/keyboard/layout/windows'
                    ],
                    title: "Stimuli <%= pkg.version %> Documentation"
                }
            }
        }

    });

    grunt.registerTask('sizzle', function(){
        var done = this.async();
        grunt.util.spawn({ cmd: 'bower', args: ['install'], opts: {stdio: 'inherit'}}, function() {
            grunt.util.spawn({ cmd: 'rm', args: ['-rf', 'lib'], opts: {stdio: 'inherit'}}, function() {
                grunt.util.spawn({ cmd: 'mv', args: ['bower_components', 'lib'], opts: {stdio: 'inherit'}}, function() {
                    grunt.util.spawn({ cmd: 'mv', args: ['lib/sizzle/dist/sizzle.js', 'lib/sizzle/'], opts: {stdio: 'inherit'}}, done);
                });
            });

        });
    });

    grunt.registerTask('phantom', function(){
        var done = this.async();
        grunt.util.spawn({
            cmd: 'karma',
            args: ['start', 'karma.phantom.conf.js', '--browsers',
                'PhantomJS'],
            opts: {stdio: 'inherit'}
        },done);
    });

    grunt.registerTask('test_coverage', function(){
        var done = this.async();
        grunt.util.spawn({
            cmd: 'karma',
            args: ['start', 'karma.coverage.conf.js', '--browsers',
                'PhantomJS,Firefox'],
            opts: {stdio: 'inherit'}
        },done);
    });

    grunt.registerTask('test_all', function(){
        var done = this.async();
        grunt.util.spawn({
            cmd: 'karma',
            args: ['start', 'karma.travis.conf.js', '--browsers',
            'BS_IE8,BS_IE9,BS_IE10,BS_IE11,BS_FIREFOX,BS_ANDROID_4,BS_ANDROID_41,BS_ANDROID_42,BS_IOS_6,BS_CHROME,BS_SAFARI51,BS_SAFARI6'
            ],
            opts: {stdio: 'inherit'}
        },done);
    });

    grunt.registerTask('watch', function(){
        var done = this.async();
        grunt.util.spawn({
            cmd: 'karma',
            args: ['start', 'karma.conf.js'],
            opts: {stdio: 'inherit'}
        },done);
    });

    grunt.registerTask('nginx_start', function(){
      var done = this.async();
      grunt.util.spawn({
        cmd: 'nginx',
        args: ['-c', '.nginx/nginx.conf', '-p', '.'],
        opts: {stdio: 'inherit'}
      },done);
    });

    grunt.registerTask('nginx_stop', function(){
      var done = this.async();
      grunt.util.spawn({
        cmd: 'nginx',
        args: ['-c', '.nginx/nginx.conf', '-p', '.', '-s', 'stop'],
        opts: {stdio: 'inherit'}
      },done);
    });

    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-jsduck');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-hub');
    grunt.loadNpmTasks('grunt-karma-coveralls');

    grunt.registerTask('build', [ 'sizzle', 'concat:dist', 'jsduck', 'copy']);

    grunt.registerTask('travis', ['jshint', 'build', 'phantom', 'test_coverage', 'coveralls', 'test_all']);

    grunt.registerTask('test_travis_local', ['nginx_start', 'build', 'test_all', 'nginx_stop']);
};<|endoftext|>