<commit_before>module.exports = function (grunt) {
    var
        project_folder = grunt.option('project') ? grunt.option('project') + '/' : './',
        path = require('path'),
        bower_dependencies = grunt.file.readJSON(project_folder + 'bower.json').dependencies,
        bower_comp = Object.keys(bower_dependencies);

    // Load all grunt tasks.
    require('load-grunt-tasks')(grunt, { config: project_folder + 'package.json' });

    // Show elapsed time at the end.
    require('time-grunt')(grunt);

    // Application configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON(project_folder + 'package.json'),

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

        'string-replace': {
            'material-design-iconic-font': {
                files: [{
                    expand: true,
                    cwd: 'bower_components/material-design-iconic-font/scss/',
                    src: '**/*',
                    dest: 'bower_components/material-design-iconic-font/scss/'
                }],
                options: {
                    replacements: [{
                        pattern: '$md-css-prefix: md;',
                        replacement: '$md-css-prefix: mdi;'
                    }]
                }
            },
            'default-tags': {
                files: [{
                    expand: true,
                    cwd: 'app/',
                    src: [
                        '**/*',
                        '!**/assets/fonts/**',
                        '!**/assets/images/**'
                    ],
                    dest: 'app/'
                }],
                options: {
                    replacements: [
                        {
                            pattern: 'fkjs_(name)',
                            replacement: '<%%= pkg.name %>'
                        },
                        {
                            pattern: 'fkjs_(title)',
                            replacement: '<%%= pkg.title %>'
                        },
                        {
                            pattern: 'fkjs_(description)',
                            replacement: '<%%= pkg.description %>'
                        },
                        {
                            pattern: 'fkjs_(version)',
                            replacement: '<%%= pkg.version %>'
                        }
                    ]
                }
            },
            'dist-tags': {
                files: [{
                    expand: true,
                    cwd: 'dist/',
                    src: [
                        '**/*',
                        '!**/assets/fonts/**',
                        '!**/assets/images/**'
                    ],
                    dest: 'dist/'
                }],
                options: {
                    replacements: [
                        {
                            pattern: 'fkjs_(name)',
                            replacement: '<%%= pkg.name %>'
                        },
                        {
                            pattern: 'fkjs_(title)',
                            replacement: '<%%= pkg.title %>'
                        },
                        {
                            pattern: 'fkjs_(description)',
                            replacement: '<%%= pkg.description %>'
                        },
                        {
                            pattern: 'fkjs_(version)',
                            replacement: '<%%= pkg.version %>'
                        }
                    ]
                }
            }
        },
        copy: {
            'bootstrap-fonts': {
                src: [
                    '**/*'
                ],
                expand: true,
                cwd: 'bower_components/bootstrap/fonts',
                dest: 'app/assets/fonts'
            },
            'material-design-iconic-font': {
                src: [
                    '**/*'
                ],
                expand: true,
                cwd: 'bower_components/material-design-iconic-font/fonts',
                dest: 'app/assets/fonts'
            },
            dist: {
                src: [
                    '**/*',
                    '!**/_test/**',
                    '!**/docs/**',
                    '!**/assets/css/**',
                    '!**/assets/scss/**',
                    '!**/src/**/*.js'
                ],
                expand: true,
                cwd: 'app',
                dest: 'dist'
            }
        },
        wiredep: {
            build: {
                src: [
                    'app/index.html'
                ],
                options: {

                }
            }
        },
        sass: {
            'material-design-iconic-font': {
                options: {
                    style: 'expanded',
                    noCache: true
                },
                files: [{
                    expand: true,
                    cwd: 'bower_components/material-design-iconic-font/scss',
                    src: ['**/*.scss'],
                    dest: 'bower_components/material-design-iconic-font/css',
                    ext: '.css'
                }]
            },
            'compile-scss': {
                options: {
                    style: 'expanded',
                    lineNumbers: true,
                    cacheLocation: 'app/assets/scss/.sass-cache'
                },
                files: [{
                    expand: true,
                    cwd: 'app/assets/scss/',
                    src: ['**/*.scss'],
                    dest: 'app/assets/scss/.temp',
                    ext: '.css'
                }]
            }
        },
        bower_concat: {
            all: {
                dest: 'dist/_bower.js',
                cssDest: 'dist/_bower.css',
                exclude: [

                ],
                mainFiles: {
                    //'script.js': 'dist/script.js'
                },
                dependencies: {

                },
                bowerOptions: {
                    relative: false
                },
                callback: function (main_files, component) {
                    var component_dependencies,
                        dependencies = [];

                    if (grunt.file.exists(project_folder + 'bower_components/' + component + '/bower.json')) {
                        component_dependencies = grunt.file.readJSON(project_folder + 'bower_components/' + component + '/bower.json').dependencies,
                        dependencies = component_dependencies ? Object.keys(component_dependencies) : [];
                    }

                    return main_files.map(function (filepath) {
                        for (i = 0; i < bower_comp.length; i++) {
                            return ((bower_comp[i].indexOf(component) > -1 || dependencies.length > -1) && component != 'script.js') ? filepath : false;
                        }
                    });
                }
            }
        },
        ngAnnotate: {
            dist: {
                files: {
                    'dist/app.js.files.js': [
                        'app/src/**/*.js'
                    ]
                }
            }
        },
        concat: {
            options: {
                //separator: ';'
            },
            'compile-css-first': {
                src: [
                    'app/assets/scss/.temp/*.css',
                    'app/assets/css/**/*.css',
                    '!**/app/assets/css/app.css',
                    '!**/app/assets/css/**/custom.css'
                ],
                dest: 'app/assets/css/app.css',
            },
            'compile-css-last': {
                src: [
                    'app/assets/css/app.css',
                    'app/assets/css/custom.css'
                ],
                dest: 'app/assets/css/app.css'
            },
            'dist-libraries': {
                src: [
                    'dist/_bower.js'
                ],
                dest: 'dist/app.libraries.js'
            },
            'dist-js-files': {
                src: [
                    'dist/app.libraries.js',
                    'dist/app.js.files.js'
                ],
                dest: 'dist/app.js'
            },
            'dist-stylesheets': {
                src: [
                    'dist/_bower.css'
                ],
                dest: 'dist/assets/css/app.css',
            },
            'dist-css-first': {
                src: [
                    'dist/_bower.css',
                    'app/assets/scss/.temp/*.css',
                    'app/assets/css/**/*.css',
                    '!**/app/assets/css/app.css',
                    '!**/app/assets/css/**/custom.css'
                ],
                dest: 'dist/assets/css/app.css',
            },
            'dist-css-last': {
                src: [
                    'dist/assets/css/app.css',
                    'app/assets/css/custom.css'
                ],
                dest: 'dist/assets/css/app.css',
            }
        },
        uglify: {
            options: {
                compress: {
                    global_defs: {
                        "DEBUG": false
                    },
                    dead_code: true
                },
                banner: '<%%= banner %>'
            },
            libraries: {
                src: 'dist/app.js',
                dest: 'dist/app.min.js'
            }
        },
        cssmin: {
            css: {
                src: 'dist/assets/css/app.css',
                dest: 'dist/assets/css/app.min.css'
            }
        },
        processhtml: {
            options: {
                data: {
                    html_tag: '<html ng-app="<%%= pkg.name %>">'
                }
            },
            dist: {
                files: {
                    'dist/index.html': ['dist/index.html']
                }
            }
        },
        clean: {
            'dist-before': [
                'dist/'
            ],
            'dist-after': [
                'app/assets/scss/.temp',
                'dist/app.js',
                'dist/app.libraries.js',
                'dist/app.js.files.js',
                'dist/assets/css/app.css',
                'dist/_bower.js',
                'dist/_bower.css',
                'dist/src/services'
            ],
            'docs': [
                'dist/docs'
            ]
        },
        watch: {
            debug: {
                files: [
                    'app/**/*',
					'!app/assets/scss/.sass-cache',
					'!app/assets/scss/.temp'
                ],
                tasks: ['compile-scss'],
                options: {
                    // Start a live reload server on the default port 35729
                    livereload: true,
                    spawn: false
                }
            }
        },
        ngdocs: {
            options: {
                dest: 'app/docs',
                startPage: '/api/app',
                html5Mode: false,
                title: '<%%= pkg.title %> Docs',
                bestMatch: true
            },
            all: [
				'app/**/*.js'
            ]
        },
        karma: {
            unit: {
                configFile: 'app/test/karma.conf.js'
            }
        }
    });

    /**
	 * @description
	 *   Now that we have loaded the package.json and the node_modules we set the base path
     *   for the actual execution of the tasks.
	 *
	 */
    grunt.file.setBase(project_folder);

    grunt.event.on('watch', function (action, filepath, target) {
        grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
    });

    /**
	 * @description
	 *   Running test task(s).
	 *
	 */
    grunt.registerTask('test', [
		'karma'
    ]);

    /**
	 * @description
	 *   Generate documentation (ngDocs) task(s).
	 *
	 */
    grunt.registerTask('docs', [
		'clean:docs',
        'ngdocs'
    ]);

    /**
	 * @description
	 *   Compile SCSS task(s).
	 *
	 */
    grunt.registerTask('compile-scss', [
        'sass:compile-scss',
        'concat:compile-css-first',
        'concat:compile-css-last'
    ]);

    /**
	 * @description
	 *   Dist task(s).
	 *
	 */
    grunt.registerTask('dist', [
        'clean:dist-before',
        'copy:dist',
        'string-replace:dist-tags',
        'processhtml',
        'bower_concat',
        'sass:compile-scss',
        'concat:dist-stylesheets',
        'concat:dist-css-first',
        'concat:dist-css-last',
        'cssmin',
        'ngAnnotate:dist',
        'concat:dist-libraries',
        'concat:dist-js-files',
        'uglify',
        'clean:dist-after'
    ]);

    /**
	 * @description
	 *   Default task(s).
	 *
	 */
    grunt.registerTask('default', [
        'copy:material-design-iconic-font',
        'string-replace:material-design-iconic-font',
        'sass:material-design-iconic-font',
        'string-replace:default-tags',
        'compile-scss',
        'wiredep:build'
    ]);
};<commit_msg>Fixed: dist exclude test folder etc.<commit_after>module.exports = function (grunt) {
    var
        project_folder = grunt.option('project') ? grunt.option('project') + '/' : './',
        path = require('path'),
        bower_dependencies = grunt.file.readJSON(project_folder + 'bower.json').dependencies,
        bower_comp = Object.keys(bower_dependencies);

    // Load all grunt tasks.
    require('load-grunt-tasks')(grunt, { config: project_folder + 'package.json' });

    // Show elapsed time at the end.
    require('time-grunt')(grunt);

    // Application configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON(project_folder + 'package.json'),

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

        'string-replace': {
            'material-design-iconic-font': {
                files: [{
                    expand: true,
                    cwd: 'bower_components/material-design-iconic-font/scss/',
                    src: '**/*',
                    dest: 'bower_components/material-design-iconic-font/scss/'
                }],
                options: {
                    replacements: [{
                        pattern: '$md-css-prefix: md;',
                        replacement: '$md-css-prefix: mdi;'
                    }]
                }
            },
            'default-tags': {
                files: [{
                    expand: true,
                    cwd: 'app/',
                    src: [
                        '**/*',
                        '!**/assets/fonts/**',
                        '!**/assets/images/**'
                    ],
                    dest: 'app/'
                }],
                options: {
                    replacements: [
                        {
                            pattern: 'fkjs_(name)',
                            replacement: '<%%= pkg.name %>'
                        },
                        {
                            pattern: 'fkjs_(title)',
                            replacement: '<%%= pkg.title %>'
                        },
                        {
                            pattern: 'fkjs_(description)',
                            replacement: '<%%= pkg.description %>'
                        },
                        {
                            pattern: 'fkjs_(version)',
                            replacement: '<%%= pkg.version %>'
                        }
                    ]
                }
            },
            'dist-tags': {
                files: [{
                    expand: true,
                    cwd: 'dist/',
                    src: [
                        '**/*',
                        '!**/assets/fonts/**',
                        '!**/assets/images/**'
                    ],
                    dest: 'dist/'
                }],
                options: {
                    replacements: [
                        {
                            pattern: 'fkjs_(name)',
                            replacement: '<%%= pkg.name %>'
                        },
                        {
                            pattern: 'fkjs_(title)',
                            replacement: '<%%= pkg.title %>'
                        },
                        {
                            pattern: 'fkjs_(description)',
                            replacement: '<%%= pkg.description %>'
                        },
                        {
                            pattern: 'fkjs_(version)',
                            replacement: '<%%= pkg.version %>'
                        }
                    ]
                }
            }
        },
        copy: {
            'bootstrap-fonts': {
                src: [
                    '**/*'
                ],
                expand: true,
                cwd: 'bower_components/bootstrap/fonts',
                dest: 'app/assets/fonts'
            },
            'material-design-iconic-font': {
                src: [
                    '**/*'
                ],
                expand: true,
                cwd: 'bower_components/material-design-iconic-font/fonts',
                dest: 'app/assets/fonts'
            },
            dist: {
                src: [
                    '**/*',
                    '!**/test/**',
                    '!**/docs/**',
                    '!**/assets/css/**',
                    '!**/assets/scss/**',
                    '!**/src/**/*.js'
                ],
                expand: true,
                cwd: 'app',
                dest: 'dist'
            }
        },
        wiredep: {
            build: {
                src: [
                    'app/index.html'
                ],
                options: {

                }
            }
        },
        sass: {
            'material-design-iconic-font': {
                options: {
                    style: 'expanded',
                    noCache: true
                },
                files: [{
                    expand: true,
                    cwd: 'bower_components/material-design-iconic-font/scss',
                    src: ['**/*.scss'],
                    dest: 'bower_components/material-design-iconic-font/css',
                    ext: '.css'
                }]
            },
            'compile-scss': {
                options: {
                    style: 'expanded',
                    lineNumbers: true,
                    cacheLocation: 'app/assets/scss/.sass-cache'
                },
                files: [{
                    expand: true,
                    cwd: 'app/assets/scss/',
                    src: ['**/*.scss'],
                    dest: 'app/assets/scss/.temp',
                    ext: '.css'
                }]
            }
        },
        bower_concat: {
            all: {
                dest: 'dist/_bower.js',
                cssDest: 'dist/_bower.css',
                exclude: [

                ],
                mainFiles: {
                    //'script.js': 'dist/script.js'
                },
                dependencies: {

                },
                bowerOptions: {
                    relative: false
                },
                callback: function (main_files, component) {
                    var component_dependencies,
                        dependencies = [];

                    if (grunt.file.exists(project_folder + 'bower_components/' + component + '/bower.json')) {
                        component_dependencies = grunt.file.readJSON(project_folder + 'bower_components/' + component + '/bower.json').dependencies,
                        dependencies = component_dependencies ? Object.keys(component_dependencies) : [];
                    }

                    return main_files.map(function (filepath) {
                        for (i = 0; i < bower_comp.length; i++) {
                            return ((bower_comp[i].indexOf(component) > -1 || dependencies.length > -1) && component != 'script.js') ? filepath : false;
                        }
                    });
                }
            }
        },
        ngAnnotate: {
            dist: {
                files: {
                    'dist/app.js.files.js': [
                        'app/src/**/*.js'
                    ]
                }
            }
        },
        concat: {
            options: {
                //separator: ';'
            },
            'compile-css-first': {
                src: [
                    'app/assets/scss/.temp/*.css',
                    'app/assets/css/**/*.css',
                    '!**/app/assets/css/app.css',
                    '!**/app/assets/css/**/custom.css'
                ],
                dest: 'app/assets/css/app.css',
            },
            'compile-css-last': {
                src: [
                    'app/assets/css/app.css',
                    'app/assets/css/custom.css'
                ],
                dest: 'app/assets/css/app.css'
            },
            'dist-libraries': {
                src: [
                    'dist/_bower.js'
                ],
                dest: 'dist/app.libraries.js'
            },
            'dist-js-files': {
                src: [
                    'dist/app.libraries.js',
                    'dist/app.js.files.js'
                ],
                dest: 'dist/app.js'
            },
            'dist-stylesheets': {
                src: [
                    'dist/_bower.css'
                ],
                dest: 'dist/assets/css/app.css',
            },
            'dist-css-first': {
                src: [
                    'dist/_bower.css',
                    'app/assets/scss/.temp/*.css',
                    'app/assets/css/**/*.css',
                    '!**/app/assets/css/app.css',
                    '!**/app/assets/css/**/custom.css'
                ],
                dest: 'dist/assets/css/app.css',
            },
            'dist-css-last': {
                src: [
                    'dist/assets/css/app.css',
                    'app/assets/css/custom.css'
                ],
                dest: 'dist/assets/css/app.css',
            }
        },
        uglify: {
            options: {
                compress: {
                    global_defs: {
                        "DEBUG": false
                    },
                    dead_code: true
                },
                banner: '<%%= banner %>'
            },
            libraries: {
                src: 'dist/app.js',
                dest: 'dist/app.min.js'
            }
        },
        cssmin: {
            css: {
                src: 'dist/assets/css/app.css',
                dest: 'dist/assets/css/app.min.css'
            }
        },
        processhtml: {
            options: {
                data: {
                    html_tag: '<html ng-app="<%%= pkg.name %>">'
                }
            },
            dist: {
                files: {
                    'dist/index.html': ['dist/index.html']
                }
            }
        },
        clean: {
            'dist-before': [
                'dist/'
            ],
            'dist-after': [
                'app/assets/scss/.temp',
                'dist/app.js',
                'dist/app.libraries.js',
                'dist/app.js.files.js',
                'dist/assets/css/app.css',
                'dist/_bower.js',
                'dist/_bower.css',
                'dist/src/services'
            ],
            'docs': [
                'dist/docs'
            ]
        },
        watch: {
            debug: {
                files: [
                    'app/**/*',
					'!app/assets/scss/.sass-cache',
					'!app/assets/scss/.temp'
                ],
                tasks: ['compile-scss'],
                options: {
                    // Start a live reload server on the default port 35729
                    livereload: true,
                    spawn: false
                }
            }
        },
        ngdocs: {
            options: {
                dest: 'app/docs',
                startPage: '/api/app',
                html5Mode: false,
                title: '<%%= pkg.title %> Docs',
                bestMatch: true
            },
            all: [
				'app/src/**/*.js',
                'app/app.bootstrap.js'
            ]
        },
        karma: {
            unit: {
                configFile: 'app/test/karma.conf.js'
            }
        }
    });

    /**
	 * @description
	 *   Now that we have loaded the package.json and the node_modules we set the base path
     *   for the actual execution of the tasks.
	 *
	 */
    grunt.file.setBase(project_folder);

    grunt.event.on('watch', function (action, filepath, target) {
        grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
    });

    /**
	 * @description
	 *   Running test task(s).
	 *
	 */
    grunt.registerTask('test', [
		'karma'
    ]);

    /**
	 * @description
	 *   Generate documentation (ngDocs) task(s).
	 *
	 */
    grunt.registerTask('docs', [
		'clean:docs',
        'ngdocs'
    ]);

    /**
	 * @description
	 *   Compile SCSS task(s).
	 *
	 */
    grunt.registerTask('compile-scss', [
        'sass:compile-scss',
        'concat:compile-css-first',
        'concat:compile-css-last'
    ]);

    /**
	 * @description
	 *   Dist task(s).
	 *
	 */
    grunt.registerTask('dist', [
        'clean:dist-before',
        'copy:dist',
        'string-replace:dist-tags',
        'processhtml',
        'bower_concat',
        'sass:compile-scss',
        'concat:dist-stylesheets',
        'concat:dist-css-first',
        'concat:dist-css-last',
        'cssmin',
        'ngAnnotate:dist',
        'concat:dist-libraries',
        'concat:dist-js-files',
        'uglify',
        'clean:dist-after'
    ]);

    /**
	 * @description
	 *   Default task(s).
	 *
	 */
    grunt.registerTask('default', [
        'copy:material-design-iconic-font',
        'string-replace:material-design-iconic-font',
        'sass:material-design-iconic-font',
        'string-replace:default-tags',
        'compile-scss',
        'wiredep:build'
    ]);
};<|endoftext|>


<commit_before>// Generated on 2013-11-23 using generator-angular 0.6.0-rc.1
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function(grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);
    var path = require('path');

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        yeoman: {
            // configurable paths
            src: 'src',
            dist: 'dist',
            build: '.tmp',
            currentDir: path.resolve(__dirname),
            banner: '/*!\n' +
                ' * <%= pkg.name %> - v<%= pkg.version %>\n' +
                ' * https://github.com/<%= pkg.author %>/<%= pkg.name %>\n' +
                ' */\n'
        },
        /** ------------- WATCH FILES FOR DEBUG PURPOSES ------------- */
        watch: {
            livereload: {
                options: {
                    livereload: '<%= express.options.livereload %>'
                },
                files: [
                    '<%= yeoman.currentDir %>/**/*.html',
                    '<%= yeoman.src %>/**/*.html',
                    'styles/{,*/}*.css',
                    '<%= yeoman.src %>/{,*/}*.js',
                    '<%= yeoman.src %>/{,*/}*.css',
                    '<%= yeoman.src %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            },
            test: {
                options: {
                    livereload: {
                        port: 35728
                    }
                },
                files: [
                    '<%= yeoman.src %>/{,*/}*.html',
                    '{<%= yeoman.build %>,<%= yeoman.src %>}/app/{,*/}*.js'
                ],
                tasks: ['test']
            }
        },
        express: {
            options: {
                port: 9000,
                hostname: '127.0.0.1',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    bases: path.resolve(__dirname)
                }
            },
            test: {
                options: {
                    port: 9001,
                    bases: [
                        'test',
                        '<%= yeoman.src %>'
                    ]
                }
            }
        },
        /** ------------- CLEAN TMP FOLDERS ------------- */
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '<%= yeoman.build %>',
                        '<%= yeoman.dist %>/*',
                        '!<%= yeoman.dist %>/.git*'
                    ]
                }]
            },
            server: '<%= yeoman.build %>'
        },
        /** ------------- FORMAT JS CODES ------------- */
        jsbeautifier: {
            files: [
                '<%= yeoman.src %>/{,*/}*.js',
                'test/{,*/}*.js',
                'Gruntfile.js'
            ],
            options: {}
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.src %>/{,*/}*.js'
            ]
        },
        /** ------------- SOURCE CODES MINIMIZATION ------------- */
        ngtemplates: {
            main: {
                options: {
                    module: '<%= ngModuleName %>',
                    base: '<%= yeoman.src %>'
                },
                src: '<%= yeoman.src %>/*.html',
                dest: '<%= yeoman.build %>/<%= moduleName %>.template.js'
            }
        },
        concat: {
            options: {
                stripBanners: true,
                banner: '<%= yeoman.banner %>'
            },
            build: {
                options: {
                    stripBanners: false
                },
                src: ['<%= yeoman.src %>/*.js',
                    '<%= yeoman.build %>/<%= moduleName %>.template.js'
                ],
                dest: '<%= yeoman.build %>/<%= moduleName %>.js'
            },
            // Copy the source files with the banner in dist folder
            banner: {
                src: ['<%= yeoman.build %>/<%= moduleName %>.js'],
                dest: '<%= yeoman.dist %>/<%= moduleName %>.js'
            },
            bannerCSS: {
                src: ['<%= yeoman.src %>/<%= moduleName %>.css'],
                dest: '<%= yeoman.dist %>/<%= moduleName %>.css'
            }
        },
        cssmin: {
            options: {
                banner: '<%= yeoman.banner %>'
            },
            dist: {
                files: {
                    '<%= yeoman.dist %>/<%= moduleName %>.min.css': [
                        '<%= yeoman.src %>/*.css'
                    ]
                }
            }
        },
        ngmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.build %>',
                    src: '*.js',
                    dest: '<%= yeoman.build %>'
                }]
            }
        },
        uglify: {
            options: {
                banner: '<%= yeoman.banner %>'
            },
            dist: {
                files: {
                    '<%= yeoman.dist %>/<%= moduleName %>.min.js': [
                        '<%= yeoman.build %>/<%= moduleName %>.js'
                    ]
                }
            }
        },
        /** ------------- JS UNIT TESTING + CODE COVERAGE ------------- */
        karma: {
            unit: {
                configFile: 'test/karma.conf.js',
                singleRun: true
            }
        }
    });

    /** ---------------------------------------------------- */
    /** ------------- GRUNT TASKS REGISTRATION ------------- */
    /** ---------------------------------------------------- */

    // Task to format js source code
    grunt.registerTask('format', [
        'jsbeautifier'
    ]);

    grunt.registerTask('test', [
        'karma'
    ]);

    grunt.registerTask('serve', [
        'clean:server',
        'express:livereload',
        'watch:livereload'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'ngtemplates',
        'concat:build',
        'ngmin',
        'cssmin',
        'uglify',
        'concat:banner',
        'concat:bannerCSS'
    ]);

    grunt.registerTask('default', [
        'format',
        'jshint',
        'test',
        'build'
    ]);
};
<commit_msg>Correct Permission DENIED when executing "grunt serve"<commit_after>// Generated on 2013-11-23 using generator-angular 0.6.0-rc.1
'use strict';

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function(grunt) {
    require('load-grunt-tasks')(grunt);
    require('time-grunt')(grunt);
    var path = require('path');

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        yeoman: {
            // configurable paths
            src: 'src',
            dist: 'dist',
            build: '.tmp',
            banner: '/*!\n' +
                ' * <%= pkg.name %> - v<%= pkg.version %>\n' +
                ' * https://github.com/<%= pkg.author %>/<%= pkg.name %>\n' +
                ' */\n'
        },
        /** ------------- WATCH FILES FOR DEBUG PURPOSES ------------- */
        watch: {
            livereload: {
                options: {
                    livereload: '<%= express.options.livereload %>'
                },
                files: [
                    '<%= yeoman.src %>/**/*.html',
                    '<%= yeoman.src %>/styles/{,*/}*.css',
                    '<%= yeoman.src %>/{,*/}*.js',
                    '<%= yeoman.src %>/{,*/}*.css',
                    '<%= yeoman.src %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            },
            test: {
                options: {
                    livereload: {
                        port: 35728
                    }
                },
                files: [
                    '<%= yeoman.src %>/{,*/}*.html',
                    '{<%= yeoman.build %>,<%= yeoman.src %>}/app/{,*/}*.js'
                ],
                tasks: ['test']
            }
        },
        express: {
            options: {
                port: 9000,
                hostname: '127.0.0.1',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    bases: path.resolve(__dirname)
                }
            },
            test: {
                options: {
                    port: 9001,
                    bases: [
                        'test',
                        '<%= yeoman.src %>'
                    ]
                }
            }
        },
        /** ------------- CLEAN TMP FOLDERS ------------- */
        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '<%= yeoman.build %>',
                        '<%= yeoman.dist %>/*',
                        '!<%= yeoman.dist %>/.git*'
                    ]
                }]
            },
            server: '<%= yeoman.build %>'
        },
        /** ------------- FORMAT JS CODES ------------- */
        jsbeautifier: {
            files: [
                '<%= yeoman.src %>/{,*/}*.js',
                'test/{,*/}*.js',
                'Gruntfile.js'
            ],
            options: {}
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.src %>/{,*/}*.js'
            ]
        },
        /** ------------- SOURCE CODES MINIMIZATION ------------- */
        ngtemplates: {
            main: {
                options: {
                    module: '<%= ngModuleName %>',
                    base: '<%= yeoman.src %>'
                },
                src: '<%= yeoman.src %>/*.html',
                dest: '<%= yeoman.build %>/<%= moduleName %>.template.js'
            }
        },
        concat: {
            options: {
                stripBanners: true,
                banner: '<%= yeoman.banner %>'
            },
            build: {
                options: {
                    stripBanners: false
                },
                src: ['<%= yeoman.src %>/*.js',
                    '<%= yeoman.build %>/<%= moduleName %>.template.js'
                ],
                dest: '<%= yeoman.build %>/<%= moduleName %>.js'
            },
            // Copy the source files with the banner in dist folder
            banner: {
                src: ['<%= yeoman.build %>/<%= moduleName %>.js'],
                dest: '<%= yeoman.dist %>/<%= moduleName %>.js'
            },
            bannerCSS: {
                src: ['<%= yeoman.src %>/<%= moduleName %>.css'],
                dest: '<%= yeoman.dist %>/<%= moduleName %>.css'
            }
        },
        cssmin: {
            options: {
                banner: '<%= yeoman.banner %>'
            },
            dist: {
                files: {
                    '<%= yeoman.dist %>/<%= moduleName %>.min.css': [
                        '<%= yeoman.src %>/*.css'
                    ]
                }
            }
        },
        ngmin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.build %>',
                    src: '*.js',
                    dest: '<%= yeoman.build %>'
                }]
            }
        },
        uglify: {
            options: {
                banner: '<%= yeoman.banner %>'
            },
            dist: {
                files: {
                    '<%= yeoman.dist %>/<%= moduleName %>.min.js': [
                        '<%= yeoman.build %>/<%= moduleName %>.js'
                    ]
                }
            }
        },
        /** ------------- JS UNIT TESTING + CODE COVERAGE ------------- */
        karma: {
            unit: {
                configFile: 'test/karma.conf.js',
                singleRun: true
            }
        }
    });

    /** ---------------------------------------------------- */
    /** ------------- GRUNT TASKS REGISTRATION ------------- */
    /** ---------------------------------------------------- */

    // Task to format js source code
    grunt.registerTask('format', [
        'jsbeautifier'
    ]);

    grunt.registerTask('test', [
        'karma'
    ]);

    grunt.registerTask('serve', [
        'clean:server',
        'express:livereload',
        'watch:livereload'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'ngtemplates',
        'concat:build',
        'ngmin',
        'cssmin',
        'uglify',
        'concat:banner',
        'concat:bannerCSS'
    ]);

    grunt.registerTask('default', [
        'format',
        'jshint',
        'test',
        'build'
    ]);
};
<|endoftext|>


<commit_before>'use strict';
var LIVERELOAD_PORT = 35729;
var SERVER_PORT = 9000;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

module.exports = function (grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);

    // Automatically load all grunt tasks by reading from package.json
    require('load-grunt-tasks')(grunt);

    // Configurable paths
    var appConfig = {
        pub: '<%= env.options.appPath %>'<% if (useServer) { %>,
        server: '<%= env.options.serverPath %>'<% } %>,
        dist: 'dist'
    };

    grunt.initConfig({
        appConfig: appConfig,
        watch: {
            // Default options for all watch tasks
            options: {
                nospawn: true,
                livereload: true
            },
            // Prevent livereload when compiling less, so that we don't force a browser refresh
            less: {
                options: {
                    livereload: false
                },
                files: ['<%%= appConfig.pub %>/less/{,*/}*.less'],
                tasks: ['less']
            },
            css: {
                options: {
                    livereload: grunt.option('livereloadport') || LIVERELOAD_PORT
                },
                files: ['{.tmp,<%%= appConfig.pub %>}/css/{,*/}*.css']
            },
            frontend: {
                options: {
                    livereload: grunt.option('livereloadport') || LIVERELOAD_PORT
                },
                files: [
                    '<%%= appConfig.pub %>/*.html',
                    '{.tmp,<%%= appConfig.pub %>}/js/{,*/}*.{js,html,tpl,mustache,hbs}',
                    '{.tmp,<%%= appConfig.pub %>}/vendor/{,*/}*.js',
                    '<%%= appConfig.pub %>/img/{,*/}*.{png,jpg,jpeg,gif,webp}',
                    'test/spec/**/*.js'
                ]
            }<% if (useServer) { %>,
            // For the express server reload we don't need to livereload the page
            // since the express server serves the backend api
            express: {
                options: {
                    nospawn: true,
                    atBegin: true,
                    livereload: false
                },
                files: ['<%%= appConfig.server %>/{,*/}*.js'],
                tasks:  ['express:dev']
            }<% } %>,
            test: {
                files: ['<%%= appConfig.server %>/{,*/}*.js', '<%%= appConfig.pub %>/js/{,*/}*.js', 'test/spec/**/*.js'],
                tasks: ['test:true']
            }
        }<% if (useServer) { %>,
        // Load the express server to provide api access
        // server also handles static files
        express: {
            options: {
                background: true,
                port: 3000
            },
            dev: {
                options: {
                    script: '<%%= appConfig.server %>/server.js',
                    node_env: 'development'
                }
            },
            dist: {
                options: {
                    background: false,
                    script: '<%%= appConfig.dist %>/server/server.js'
                }
            }
        }<% } %>,
        connect: {
            options: {
                port: grunt.option('port') || SERVER_PORT,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, appConfig.pub)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test'),
                            mountFolder(connect, appConfig.pub)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, appConfig.dist + '/public')
                        ];
                    }
                }
            }
        },
        open: {
            <% if (useServer) { %>
            server: {
                path: 'http://localhost:<%%= express.options.port %>',
                options: {
                    delay: 1000
                }
            }<%} else {%>
            server: {
                path: 'http://localhost:<%%= connect.options.port %>',
                options: {
                    delay: 1000
                }
            }
            <%}%>,
            test: {
                path: 'http://localhost:<%%= connect.test.options.port %>'
            }
        },
        clean: {
            dist: ['.tmp', '<%%= appConfig.dist %>/*'],
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                '<%%= appConfig.pub %>/js/{,*/}*.js',
                '!<%%= appConfig.pub %>/vendor/*',
                'test/spec/{,*/}*.js'
            ]
        }<% if (testFramework === 'mocha') { %>,
        mocha: {
            all: {
                options: {
                    run: true,
                    src: ['http://localhost:<%%= connect.test.options.port %>/index.html']
                }
            }
        }<% } else { %>,
        jasmine: {
            all:{
                src : '<%%= appConfig.pub %>/scripts/{,*/}*.js',
                options: {
                    keepRunner: true,
                    specs : 'test/spec/**/*.js',
                    vendor : [
                        '<%%= appConfig.pub %>/bower_components/jquery/dist/jquery.js',
                        '<%%= appConfig.pub %>/bower_components/underscore/underscore.js',
                        '<%%= appConfig.pub %>/bower_components/backbone/backbone.js',
                        '.tmp/scripts/templates.js'
                    ]
                }
            }
        }<% } %>,<% if (compassBootstrap) { %>
        compass: {
            options: {
                sassDir: '<%%=appConfig.pub %>/sass',
                cssDir: '.tmp/styles',
                imagesDir: '<%%=appConfig.pub %>/img',
                javascriptsDir: '<%%=appConfig.pub %>/js',
                fontsDir: '<%%=appConfig.pub %>/css/fonts',
                importPath: '<%%=appConfig.pub %>/vendor',
                relativeAssets: true
            },
            dist: {},
            server: {
                options: {
                    debugInfo: true
                }
            }
        },<% } %>
        less: {
            development: {
                files: {
                    '<%%= appConfig.pub %>/css/main.css': '<%%= appConfig.pub %>/less/main.less'
                }
            }
        },
        requirejs: {
            dist: {
                // Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
                options: {
                    almond: true,
                    // replace require script calls, with the almond modules
                    // in the following files
                    replaceRequireScript: [{
                        files: ['<%%= appConfig.dist %>/public/index.html'],
                        module: 'main'
                    }],
                    baseUrl: '<%%= appConfig.pub %>/js',
                    mainConfigFile: "<%%= appConfig.pub %>/js/main.js",
                    include: ["main"],
                    out: "<%%= appConfig.dist %>/public/js/main.js",
                    // Modify some modules as we optimize them
                    onBuildWrite   : function( name, path, contents ) {
                        // Backbone.NestedModel needs to be upgraded to an AMD
                        // module since by default it looks for Backbone as a global.
                        // An optimized build will fail since the global isn't created until
                        // the dependency is needed by a module
                        if (name === 'backboneNestedModel') {
                            return "define('"+name+"', ['backbone'],function(Backbone){"+contents+"})";
                        } else {
                            // Return module unmodifed
                            return contents;
                        }
                    },
                    preserveLicenseComments: false,
                    useStrict: false,
                    wrap: true
                }
            }
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%%= appConfig.pub %>/img',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%%= appConfig.dist %>/public/img'
                }]
            }
        },
        cssmin: {
            dist: {
                files: {
                    '<%%= appConfig.dist %>/public/css/main.css': [
                        '.tmp/styles/{,*/}*.css',
                        '<%%= appConfig.pub %>/css/{,*/}*.css'
                    ]
                }
            }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                    // https://github.com/yeoman/grunt-usemin/issues/44
                    //collapseWhitespace: true,
                    collapseBooleanAttributes: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%%= appConfig.pub %>',
                    src: '*.html',
                    dest: '<%%= appConfig.dist %>/public/'
                }]
            }
        },
        // Copies additional files to distrubution folder (other than .html and css files)
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%%= appConfig.pub %>',
                    dest: '<%%= appConfig.dist %>/public',
                    src: [
                        '*.{ico,txt}',
                        '.htaccess',
                        'img/{,*/}*.{webp,gif}',
                        'vendor/sp-bootstrap/fonts/*.*'
                    ]
                }<% if (useServer) { %>,{
                    expand: true,
                    dot: true,
                    cwd: '<%%= appConfig.server %>',
                    dest: '<%%= appConfig.dist %>/server',
                    src: [
                        '*'
                    ]
                }<%}%>]
            }
        },
        bower: {
            app: {
                rjsConfig: '<%%= appConfig.pub %>/js/main.js'
            }
        }
    });

    grunt.registerTask('serve', function (target) {
        if (target === 'dist') {
            <% if (useServer) { %>
                return grunt.task.run(['build', 'open:server', 'express:dev']);
            <%} else {%>
                return grunt.task.run(['build', 'open:server', 'connect:dist:keepalive']);
            <%}%>
        }

        <% if (useServer) { %>
            if (target === 'test') {
                return grunt.task.run([
                    'clean:server',
                    'connect:test',
                    'open:test',
                    'watch'
                ]);
            }
        <%} else {%>
            if (target === 'test') {
                return grunt.task.run([
                    'clean:server',<% if (compassBootstrap) { %>
                    'compass:server',<% } %>
                    'connect:test',
                    'open:test',
                    'watch'
                ]);
            }
        <%}%>

        <% if (useServer) { %>
            grunt.task.run([
                'clean:server',
                'open:server',
                'watch'
            ]);
        <%} else {%>
            grunt.task.run([
                'clean:server',<% if (compassBootstrap) { %>
                'compass:server',<% } %>
                'connect:livereload',
                'open:server',
                'watch'
            ]);
        <%}%>
    });

    grunt.registerTask('test', function (isConnected) {
        isConnected = Boolean(isConnected);
        var testTasks = [
                'clean:server',
                'connect:test',
                'mocha',
            ];

        if(!isConnected) {
            return grunt.task.run(testTasks);
        } else {
            // already connected so not going to connect again, remove the connect:test task
            testTasks.splice(testTasks.indexOf('connect:test'), 1);
            return grunt.task.run(testTasks);
        }
    });

    grunt.registerTask('build', [
        'clean:dist',<% if (compassBootstrap) { %>
        'compass:dist',<% } %>
        'htmlmin',
        'requirejs',
        'less',
        'imagemin',
        'cssmin',
        'copy'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'test',
        'build'
    ]);
};
<commit_msg>fix(grunt): add development flag to dist serving<commit_after>'use strict';
var LIVERELOAD_PORT = 35729;
var SERVER_PORT = 9000;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

module.exports = function (grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);

    // Automatically load all grunt tasks by reading from package.json
    require('load-grunt-tasks')(grunt);

    // Configurable paths
    var appConfig = {
        pub: '<%= env.options.appPath %>'<% if (useServer) { %>,
        server: '<%= env.options.serverPath %>'<% } %>,
        dist: 'dist'
    };

    grunt.initConfig({
        appConfig: appConfig,
        watch: {
            // Default options for all watch tasks
            options: {
                nospawn: true,
                livereload: true
            },
            // Prevent livereload when compiling less, so that we don't force a browser refresh
            less: {
                options: {
                    livereload: false
                },
                files: ['<%%= appConfig.pub %>/less/{,*/}*.less'],
                tasks: ['less']
            },
            css: {
                options: {
                    livereload: grunt.option('livereloadport') || LIVERELOAD_PORT
                },
                files: ['{.tmp,<%%= appConfig.pub %>}/css/{,*/}*.css']
            },
            frontend: {
                options: {
                    livereload: grunt.option('livereloadport') || LIVERELOAD_PORT
                },
                files: [
                    '<%%= appConfig.pub %>/*.html',
                    '{.tmp,<%%= appConfig.pub %>}/js/{,*/}*.{js,html,tpl,mustache,hbs}',
                    '{.tmp,<%%= appConfig.pub %>}/vendor/{,*/}*.js',
                    '<%%= appConfig.pub %>/img/{,*/}*.{png,jpg,jpeg,gif,webp}',
                    'test/spec/**/*.js'
                ]
            }<% if (useServer) { %>,
            // For the express server reload we don't need to livereload the page
            // since the express server serves the backend api
            express: {
                options: {
                    nospawn: true,
                    atBegin: true,
                    livereload: false
                },
                files: ['<%%= appConfig.server %>/{,*/}*.js'],
                tasks:  ['express:dev']
            }<% } %>,
            test: {
                files: ['<%%= appConfig.server %>/{,*/}*.js', '<%%= appConfig.pub %>/js/{,*/}*.js', 'test/spec/**/*.js'],
                tasks: ['test:true']
            }
        }<% if (useServer) { %>,
        // Load the express server to provide api access
        // server also handles static files
        express: {
            options: {
                background: true,
                port: 3000
            },
            dev: {
                options: {
                    script: '<%%= appConfig.server %>/server.js',
                    node_env: 'development'
                }
            },
            dist: {
                options: {
                    background: false,
                    script: '<%%= appConfig.dist %>/server/server.js',
                    node_env: 'development'
                }
            }
        }<% } %>,
        connect: {
            options: {
                port: grunt.option('port') || SERVER_PORT,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, appConfig.pub)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test'),
                            mountFolder(connect, appConfig.pub)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, appConfig.dist + '/public')
                        ];
                    }
                }
            }
        },
        open: {
            <% if (useServer) { %>
            server: {
                path: 'http://localhost:<%%= express.options.port %>',
                options: {
                    delay: 1000
                }
            }<%} else {%>
            server: {
                path: 'http://localhost:<%%= connect.options.port %>',
                options: {
                    delay: 1000
                }
            }
            <%}%>,
            test: {
                path: 'http://localhost:<%%= connect.test.options.port %>'
            }
        },
        clean: {
            dist: ['.tmp', '<%%= appConfig.dist %>/*'],
            server: '.tmp'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                'Gruntfile.js',
                '<%%= appConfig.pub %>/js/{,*/}*.js',
                '!<%%= appConfig.pub %>/vendor/*',
                'test/spec/{,*/}*.js'
            ]
        }<% if (testFramework === 'mocha') { %>,
        mocha: {
            all: {
                options: {
                    run: true,
                    src: ['http://localhost:<%%= connect.test.options.port %>/index.html']
                }
            }
        }<% } else { %>,
        jasmine: {
            all:{
                src : '<%%= appConfig.pub %>/scripts/{,*/}*.js',
                options: {
                    keepRunner: true,
                    specs : 'test/spec/**/*.js',
                    vendor : [
                        '<%%= appConfig.pub %>/bower_components/jquery/dist/jquery.js',
                        '<%%= appConfig.pub %>/bower_components/underscore/underscore.js',
                        '<%%= appConfig.pub %>/bower_components/backbone/backbone.js',
                        '.tmp/scripts/templates.js'
                    ]
                }
            }
        }<% } %>,<% if (compassBootstrap) { %>
        compass: {
            options: {
                sassDir: '<%%=appConfig.pub %>/sass',
                cssDir: '.tmp/styles',
                imagesDir: '<%%=appConfig.pub %>/img',
                javascriptsDir: '<%%=appConfig.pub %>/js',
                fontsDir: '<%%=appConfig.pub %>/css/fonts',
                importPath: '<%%=appConfig.pub %>/vendor',
                relativeAssets: true
            },
            dist: {},
            server: {
                options: {
                    debugInfo: true
                }
            }
        },<% } %>
        less: {
            development: {
                files: {
                    '<%%= appConfig.pub %>/css/main.css': '<%%= appConfig.pub %>/less/main.less'
                }
            }
        },
        requirejs: {
            dist: {
                // Options: https://github.com/jrburke/r.js/blob/master/build/example.build.js
                options: {
                    almond: true,
                    // replace require script calls, with the almond modules
                    // in the following files
                    replaceRequireScript: [{
                        files: ['<%%= appConfig.dist %>/public/index.html'],
                        module: 'main'
                    }],
                    baseUrl: '<%%= appConfig.pub %>/js',
                    mainConfigFile: "<%%= appConfig.pub %>/js/main.js",
                    include: ["main"],
                    out: "<%%= appConfig.dist %>/public/js/main.js",
                    // Modify some modules as we optimize them
                    onBuildWrite   : function( name, path, contents ) {
                        // Backbone.NestedModel needs to be upgraded to an AMD
                        // module since by default it looks for Backbone as a global.
                        // An optimized build will fail since the global isn't created until
                        // the dependency is needed by a module
                        if (name === 'backboneNestedModel') {
                            return "define('"+name+"', ['backbone'],function(Backbone){"+contents+"})";
                        } else {
                            // Return module unmodifed
                            return contents;
                        }
                    },
                    preserveLicenseComments: false,
                    useStrict: false,
                    wrap: true
                }
            }
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%%= appConfig.pub %>/img',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%%= appConfig.dist %>/public/img'
                }]
            }
        },
        cssmin: {
            dist: {
                files: {
                    '<%%= appConfig.dist %>/public/css/main.css': [
                        '.tmp/styles/{,*/}*.css',
                        '<%%= appConfig.pub %>/css/{,*/}*.css'
                    ]
                }
            }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                    // https://github.com/yeoman/grunt-usemin/issues/44
                    //collapseWhitespace: true,
                    collapseBooleanAttributes: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%%= appConfig.pub %>',
                    src: '*.html',
                    dest: '<%%= appConfig.dist %>/public/'
                }]
            }
        },
        // Copies additional files to distrubution folder (other than .html and css files)
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%%= appConfig.pub %>',
                    dest: '<%%= appConfig.dist %>/public',
                    src: [
                        '*.{ico,txt}',
                        '.htaccess',
                        'img/{,*/}*.{webp,gif}',
                        'vendor/sp-bootstrap/fonts/*.*'
                    ]
                }<% if (useServer) { %>,{
                    expand: true,
                    dot: true,
                    cwd: '<%%= appConfig.server %>',
                    dest: '<%%= appConfig.dist %>/server',
                    src: [
                        '*'
                    ]
                }<%}%>]
            }
        },
        bower: {
            app: {
                rjsConfig: '<%%= appConfig.pub %>/js/main.js'
            }
        }
    });

    grunt.registerTask('serve', function (target) {
        if (target === 'dist') {
            <% if (useServer) { %>
                return grunt.task.run(['build', 'open:server', 'express:dist']);
            <%} else {%>
                return grunt.task.run(['build', 'open:server', 'connect:dist:keepalive']);
            <%}%>
        }

        <% if (useServer) { %>
            if (target === 'test') {
                return grunt.task.run([
                    'clean:server',
                    'connect:test',
                    'open:test',
                    'watch'
                ]);
            }
        <%} else {%>
            if (target === 'test') {
                return grunt.task.run([
                    'clean:server',<% if (compassBootstrap) { %>
                    'compass:server',<% } %>
                    'connect:test',
                    'open:test',
                    'watch'
                ]);
            }
        <%}%>

        <% if (useServer) { %>
            grunt.task.run([
                'clean:server',
                'open:server',
                'watch'
            ]);
        <%} else {%>
            grunt.task.run([
                'clean:server',<% if (compassBootstrap) { %>
                'compass:server',<% } %>
                'connect:livereload',
                'open:server',
                'watch'
            ]);
        <%}%>
    });

    grunt.registerTask('test', function (isConnected) {
        isConnected = Boolean(isConnected);
        var testTasks = [
                'clean:server',
                'connect:test',
                'mocha',
            ];

        if(!isConnected) {
            return grunt.task.run(testTasks);
        } else {
            // already connected so not going to connect again, remove the connect:test task
            testTasks.splice(testTasks.indexOf('connect:test'), 1);
            return grunt.task.run(testTasks);
        }
    });

    grunt.registerTask('build', [
        'clean:dist',<% if (compassBootstrap) { %>
        'compass:dist',<% } %>
        'htmlmin',
        'requirejs',
        'less',
        'imagemin',
        'cssmin',
        'copy'
    ]);

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


<commit_before>import axios from 'axios'
import { API } from './constants'

const handleError = err => {
  throw new Error(err)
}

const checkIfHasToken = token =>
  token || handleError('O token é obrigatório para autenticação.')

const fetchData = token => {
  const validateHttpStatus = res => {
    res.status === 200 || handleError('Erro ao se conectar com o serviço da SPTrans.')
    return res
  }

  const validateToken = res => {
    res.data || handleError('Token inválido.')
    return res
  }

  const setCredentials = res => res.headers['set-cookie'][0]

  const config = {
    method: 'post',
    url: API.endpoint + API.auth.route,
    params: { token }
  }

  return axios(config)
    .then(validateHttpStatus)
    .then(validateToken)
    .then(setCredentials)
}

export default token =>
  Promise.resolve(token)
    .then(checkIfHasToken)
    .then(fetchData)
<commit_msg>Update auth method for better readable<commit_after>import axios from 'axios'
import { API } from './constants'

const handleError = err => {
  throw new Error(err)
}

const checkIfHasToken = token =>
  token || handleError('O token é obrigatório para autenticação.')

const validateHttpStatus = res => {
  res.status === 200 || handleError('Erro ao se conectar com o serviço da SPTrans.')
  return res
}

const validateToken = res => {
  res.data || handleError('Token inválido.')
  return res
}

const setCredentials = res => res.headers['set-cookie'][0]

const fetchData = token => {
  const config = {
    method: 'post',
    url: API.endpoint + API.auth.route,
    params: { token }
  }

  return axios(config)
    .then(validateHttpStatus)
    .then(validateToken)
    .then(setCredentials)
}

export default token =>
  Promise.resolve(token)
    .then(checkIfHasToken)
    .then(fetchData)
<|endoftext|>


<commit_before>KityMinder.registerProtocal('plain', function() {
    var LINE_ENDING = /\r\n|\r|\n/,
        TAB_CHAR = '\t';

    function repeat(s, n) {
        var result = '';
        while (n--) result += s;
        return result;
    }

    function encode(json, level) {
        var local = '';
        level = level || 0;
        local += repeat(TAB_CHAR, level);
        local += json.data.text + LINE_ENDING;
        if (json.children) {
            json.children.forEach(function(child) {
                local += encode(child, level + 1);
            });
        }
        return local;
    }

    function isEmpty(line) {
        return !/\S/.test(line);
    }

    function getLevel(line) {
        var level = 0;
        while (line.charAt(level) === TAB_CHAR) level++;
        return level;
    }

    function getNode(line) {
        return {
            data: {
                text: line.replace(new RegExp('^' + TAB_CHAR + '*'), '')
            }
        };
    }

    function decode(local) {
        var json,
            parentMap = {},
            lines = local.split(LINE_ENDING),
            line, level, node;

        function addChild(parent, child) {
            var children = parent.children || (parent.children = []);
            children.push(child);
        }

        for (var i = 0; i < lines.length; i++) {
            line = lines[i];
            if (isEmpty(line)) continue;

            level = getLevel(line);
            node = getNode(line);

            if (level === 0) {
                if (json) {
                    throw new Error('Invalid local format');
                }
                json = node;
            } else {
                if (!parentMap[level - 1]) {
                    throw new Error('Invalid local format');
                }
                addChild(parentMap[level - 1], node);
            }
            parentMap[level] = node;
        }
        return json;
    }
    var lastTry, lastResult;

    function recognize(local) {
        if (!Utils.isString(local)) return false;
        lastTry = local;
        try {
            lastResult = decode(local);
        } catch (e) {
            lastResult = null;
        }
        return !!lastResult;
    }

    return {
        fileDescription: '大纲文本',
        fileExtension: '.txt',
        mineType: 'text/plain',
        encode: function(json) {
            return encode(json, 0);
        },
        decode: function(local) {
            if (lastTry == local && lastResult) {
                return lastResult;
            }
            return decode(local);
        },
        recognize: recognize,
        recognizePriority: -1
    };
});<commit_msg>fix plain protocal issue<commit_after>KityMinder.registerProtocal('plain', function() {
    var LINE_ENDING = '\r',
        LINE_ENDING_SPLITER = /\r\n|\r|\n/,
        TAB_CHAR = '\t';

    function repeat(s, n) {
        var result = '';
        while (n--) result += s;
        return result;
    }

    function encode(json, level) {
        var local = '';
        level = level || 0;
        local += repeat(TAB_CHAR, level);
        local += json.data.text + LINE_ENDING;
        if (json.children) {
            json.children.forEach(function(child) {
                local += encode(child, level + 1);
            });
        }
        return local;
    }

    function isEmpty(line) {
        return !/\S/.test(line);
    }

    function getLevel(line) {
        var level = 0;
        while (line.charAt(level) === TAB_CHAR) level++;
        return level;
    }

    function getNode(line) {
        return {
            data: {
                text: line.replace(new RegExp('^' + TAB_CHAR + '*'), '')
            }
        };
    }

    function decode(local) {
        var json,
            parentMap = {},
            lines = local.split(LINE_ENDING_SPLITER),
            line, level, node;

        function addChild(parent, child) {
            var children = parent.children || (parent.children = []);
            children.push(child);
        }

        for (var i = 0; i < lines.length; i++) {
            line = lines[i];
            if (isEmpty(line)) continue;

            level = getLevel(line);
            node = getNode(line);

            if (level === 0) {
                if (json) {
                    throw new Error('Invalid local format');
                }
                json = node;
            } else {
                if (!parentMap[level - 1]) {
                    throw new Error('Invalid local format');
                }
                addChild(parentMap[level - 1], node);
            }
            parentMap[level] = node;
        }
        return json;
    }
    var lastTry, lastResult;

    function recognize(local) {
        if (!Utils.isString(local)) return false;
        lastTry = local;
        try {
            lastResult = decode(local);
        } catch (e) {
            lastResult = null;
        }
        return !!lastResult;
    }

    return {
        fileDescription: '大纲文本',
        fileExtension: '.txt',
        mineType: 'text/plain',
        encode: function(json) {
            return encode(json, 0);
        },
        decode: function(local) {
            if (lastTry == local && lastResult) {
                return lastResult;
            }
            return decode(local);
        },
        recognize: recognize,
        recognizePriority: -1
    };
});<|endoftext|>


<commit_before>/***********************************************
||          WELCOME TO EGGS GENNNY's          ||
||                gulpfile.js                 ||
||                                            ||
||     Alter to suit your needs, this is      ||
||          just a starting place =)          ||
||                                            ||
************************************************/

/***********************************************
**               Require Stuff                **
************************************************/
var gulp   = require('gulp'),
    chalk  = require('chalk'),
    del    = require('del'),
    plug   = require('gulp-load-plugins')({
              scope: ['devDependencies'],
              replaceString: 'gulp-',
            }),
//  Here's where you can specify which browsers Autoprefixer tests against
//  The default you see here goes back really far, in reality something like 'last 2 versions' gets you > 90% coverage
    supportedBrowsers = [ 'last 4 versions', '> 0.5%', 'ie 7', 'ff 3', 'Firefox ESR', 'Android 2.1' ];

/***********************************************
**          Default Task (dev/watch)          **
************************************************/
gulp.task( 'default', ['reload-me']);

/***********************************************
**          Development/Watch Task            **
************************************************/
gulp.task( 'reload-me', function(){
  plug.livereload.listen();
  gulp.watch( 'app/css/*.less', ['compile-me'] );
  gulp.watch( ['app/css/*.css', 'app/js/*.js', 'app/index.html'<% if(deps.angular){ %>, 'app/partials/*.html'<% } %> ], function(){
    loggit("I've reloaded your page, <% if(greeting === 'sir'){ %>sir!<% }else{ %>ma'am!<% } %>\n    "+timePlz());
  })
  .on('change', plug.livereload.changed);
});

/***********************************************
**                   build                    **
************************************************/

gulp.task( 'build', [ 'compile-me', 'css-me', 'annotate-me', 'js-me', 'assets-me', 'html-me', 'clean-me', 'uncss-me' ]);

//  LESS compile
gulp.task( 'compile-me', function(){

  return gulp.src('app/css/*.less')
          .pipe( plug.less() )
          .on('error', errorLog)
          .pipe( gulp.dest('app/css/') );

});
//  CSSTASKS
gulp.task( 'css-me', ['compile-me'], function(){

  return  gulp.src( [ <% if (deps.bootstrap) { %>'app/lib/bootstrap.css',<% } %> 'app/css/*.css' ] )
            .pipe( plug.concat('styles.css') )
            .pipe( gulp.dest( 'tmp/css' ) )
            .pipe( plug.autoprefixer({
                      browsers: supportedBrowsers,
                      cascade: false
                    }))
            .pipe( plug.csscomb() )
            .pipe( plug.minifyCss() )
            .pipe( gulp.dest( 'build/css/' ) );

});
gulp.task( 'uncss-me', ['css-me', 'assets-me', 'html-me'], function(){

  return gulp.src('build/css/styles.css')
          .pipe(plug.uncss({
            html: ['build/index.html'<% if (deps.angular) { %>, 'build/partials/*.html'<% } %>]
          }))
          .pipe(gulp.dest('build/css/'));
});

//  JSTASKS
gulp.task( 'annotate-me',  function(){

  return  gulp.src( 'app/js/app.js' )
          .pipe( plug.ngAnnotate() )
          .on('error', errorLog)
          .pipe(gulp.dest('app/js/'));

});
gulp.task( 'js-me', ['annotate-me'], function(){

  return  gulp.src([<% if (deps.jquery) { %>
                  'app/lib/js/jquery.js',<% } if(deps.gsap){ %>
                  'app/lib/js/TweenMax.min.js',
                  'app/lib/js/TimelineMax.js',
                  'app/lib/js/CSSPlugin.js',
                  'app/lib/js/EasePack.js',<% } if(deps.angular){ %>
                  'app/lib/js/angular.js',<% } %>
                  'app/js/*.js' ])
          .pipe( plug.concat('scripts.js') )
          .pipe( gulp.dest( 'tmp/js' ) )
          .pipe( plug.uglify( {mangle: false} ) )
          .pipe( gulp.dest( 'build/js' ) );

});

//MOVE ASSETS
gulp.task( 'assets-me', function(){

<%  if(deps.angular){ %>//  PARTIALS
  gulp.src( 'app/partials/*' )
    .pipe(plug.angularHtmlify())
    .pipe( gulp.dest('build/partials/') );
  <% } %>//  IMAGES
  gulp.src( 'app/img/*' )
    .pipe(plug.imagemin({
      progressive: true,
      optimizationLevel: 5
    }))
    .pipe( gulp.dest('build/img/') );
  //  Favicon move
  gulp.src( 'app/favicon.ico' )
    .pipe( gulp.dest('build/favicon.ico') );

})

//HTMLMOVE/REPLACE
gulp.task( 'html-me', function(){

  return gulp.src( 'app/index.html' )<%  if(deps.angular){ %>
              .pipe(plug.angularHtmlify())
              <% } %>.pipe(plug.htmlReplace({
                css: {
                  src: 'css/styles.css',
                  tpl: '  <link rel="stylesheet" type="text/css" href="%s" />'
                },
                js: {
                  src: 'js/scripts.js',
                  tpl: '  <script type="text/javascript" src="%s"></script>'
                }
            }))
            .pipe(gulp.dest( 'build/' ));
});

gulp.task( 'clean-me', [ 'css-me', 'js-me' ], function(){

  var dels = 'Cleaned up the following: \n';
  del( ['tmp/**','tmp'] , function (err, deletedFiles) {
    deletedFiles.forEach( function( val, index ){
        dels +=  '  - '+val+'\n';
    })
    loggit(dels);
  });

});

/***********************************************
**          Utility/Logging Functions         **
**   Nothing (gulp) to see here, move along   **
************************************************/
function loggit(l){
  var log = "*****************************************\n"+
            " - "+l+"\n"+
            "*****************************************\n"
  console.log( chalk.cyan(log) );
}

function errorLog(er){
  var log = "*****************************************\n"+
            "**          CATASTROPHIC ERROR!        **\n"+
            "**                                     **\n"+
            "**       User attempted to use the     **\n"+
            "**     program in the manner it was    **\n"+
            "**          intended to be used!       **\n"+
            "**                                     **\n"+
            "              ERROR MESSAGE:             \n"+
            " - "+er+"\n"+
            "*****************************************\n";

  console.log( chalk.red( log )  );
}

function timePlz(){

  var D  = new Date(),
      h  = D.getHours(),
      m  = D.getMinutes(),
      s  = D.getSeconds(),
      dt = D.getDate(),
      yr = D.getFullYear(),
      months = [
        "January",
        "February",
        "March",
        "April",
        "May",
        "June",
        "July",
        "August",
        "September",
        "October",
        "November",
        "December"
      ],
      mt = months[D.getMonth()];

      //  convert to 12 hour time
      if(h > 12){ h = h - 12 };
      if(h === 0){ h = 12 };

      //  in case seconds is lower than 10
      if( s < 10 ){ s = '0' + s }

      return mt + ' ' + dt + ', ' + yr + ' at ' + h + ':' + m + ':' + s;

}
<commit_msg>adds a warning to uncss-task<commit_after>/***********************************************
||          WELCOME TO EGGS GENNNY's          ||
||                gulpfile.js                 ||
||                                            ||
||     Alter to suit your needs, this is      ||
||          just a starting place =)          ||
||                                            ||
************************************************/

/***********************************************
**               Require Stuff                **
************************************************/
var gulp   = require('gulp'),
    chalk  = require('chalk'),
    del    = require('del'),
    plug   = require('gulp-load-plugins')({
              scope: ['devDependencies'],
              replaceString: 'gulp-',
            }),
//  Here's where you can specify which browsers Autoprefixer tests against
//  The default you see here goes back really far, in reality something like 'last 2 versions' gets you > 90% coverage
    supportedBrowsers = [ 'last 4 versions', '> 0.5%', 'ie 7', 'ff 3', 'Firefox ESR', 'Android 2.1' ];

/***********************************************
**          Default Task (dev/watch)          **
************************************************/
gulp.task( 'default', ['reload-me']);

/***********************************************
**          Development/Watch Task            **
************************************************/
gulp.task( 'reload-me', function(){
  plug.livereload.listen();
  gulp.watch( 'app/css/*.less', ['compile-me'] );
  gulp.watch( ['app/css/*.css', 'app/js/*.js', 'app/index.html'<% if(deps.angular){ %>, 'app/partials/*.html'<% } %> ], function(){
    loggit("I've reloaded your page, <% if(greeting === 'sir'){ %>sir!<% }else{ %>ma'am!<% } %>\n    "+timePlz());
  })
  .on('change', plug.livereload.changed);
});

/***********************************************
**                   build                    **
************************************************/

gulp.task( 'build', [ 'compile-me', 'css-me', 'annotate-me', 'js-me', 'assets-me',<% if (deps.angular) { %> 'partials-me',<% } %> 'html-me', 'clean-me', 'uncss-me' ]);

//  LESS compile
gulp.task( 'compile-me', function(){

  return gulp.src('app/css/*.less')
          .pipe( plug.less() )
          .on('error', errorLog)
          .pipe( gulp.dest('app/css/') );

});
//  CSSTASKS
gulp.task( 'css-me', ['compile-me'], function(){

  return  gulp.src( [ <% if (deps.bootstrap) { %>'app/lib/bootstrap.css',<% } %> 'app/css/*.css' ] )
            .pipe( plug.concat('styles.css') )
            .pipe( gulp.dest( 'tmp/css' ) )
            .pipe( plug.autoprefixer({
                      browsers: supportedBrowsers,
                      cascade: false
                    }))
            .pipe( plug.csscomb() )
            .pipe( plug.minifyCss() )
            .pipe( gulp.dest( 'build/css/' ) );

});
gulp.task( 'uncss-me', ['css-me',<% if (deps.angular) { %> 'partials-me',<% } %> 'html-me'], function(){
  <% if (deps.angular) { %>
    //  Alert for angular users to add partials to the uncss task.
    //  You can delete once you've seen this message
    console.log(chalk.red(  '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n'+
                            '           WARNING!             \n'+
                            ' Add your partial files to the  \n'+
                            ' uncss task or their css will   \n'+
                            ' be stripped out!!              \n'+
                            '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n');

  <% } %>return gulp.src('build/css/styles.css')
          .pipe(plug.uncss({
            //  UNCSS (sadly) does not support globbing, so 'build/partials/*.html' does not work here
            //  Manually add your partial files to this array so they can be parsed
            html: ['build/index.html']
          }))
          .pipe(gulp.dest('build/css/'));
});

//  JSTASKS
gulp.task( 'annotate-me',  function(){

  return  gulp.src( 'app/js/app.js' )
          .pipe( plug.ngAnnotate() )
          .on('error', errorLog)
          .pipe(gulp.dest('app/js/'));

});
gulp.task( 'js-me', ['annotate-me'], function(){

  return  gulp.src([<% if (deps.jquery) { %>
                  'app/lib/js/jquery.js',<% } if(deps.gsap){ %>
                  'app/lib/js/TweenMax.min.js',
                  'app/lib/js/TimelineMax.js',
                  'app/lib/js/CSSPlugin.js',
                  'app/lib/js/EasePack.js',<% } if(deps.angular){ %>
                  'app/lib/js/angular.js',<% } %>
                  'app/js/*.js' ])
          .pipe( plug.concat('scripts.js') )
          .pipe( gulp.dest( 'tmp/js' ) )
          .pipe( plug.uglify( {mangle: false} ) )
          .pipe( gulp.dest( 'build/js' ) );

});

//MOVE ASSETS
gulp.task( 'assets-me', function(){

  //  IMAGES
  gulp.src( 'app/img/*' )
    .pipe(plug.imagemin({
      progressive: true,
      optimizationLevel: 5
    }))
    .pipe( gulp.dest('build/img/') );
  //  Favicon move
  gulp.src( 'app/favicon.ico' )
    .pipe( gulp.dest('build/favicon.ico') );

});<%  if(deps.angular){ %>

gulp.task( 'partials-me', function(){

  return gulp.src( 'app/partials/*' )
          .pipe(plug.angularHtmlify())
          .pipe( gulp.dest('build/partials/') );

});<% } %>

//HTMLMOVE/REPLACE
gulp.task( 'html-me', function(){

  return gulp.src( 'app/index.html' )<%  if(deps.angular){ %>
              .pipe(plug.angularHtmlify())
              <% } %>.pipe(plug.htmlReplace({
                css: {
                  src: 'css/styles.css',
                  tpl: '  <link rel="stylesheet" type="text/css" href="%s" />'
                },
                js: {
                  src: 'js/scripts.js',
                  tpl: '  <script type="text/javascript" src="%s"></script>'
                }
            }))
            .pipe(gulp.dest( 'build/' ));
});

gulp.task( 'clean-me', [ 'css-me', 'js-me' ], function(){

  var dels = 'Cleaned up the following: \n';
  del( ['tmp/**','tmp'] , function (err, deletedFiles) {
    deletedFiles.forEach( function( val, index ){
        dels +=  '  - '+val+'\n';
    })
    loggit(dels);
  });

});

/***********************************************
**          Utility/Logging Functions         **
**   Nothing (gulp) to see here, move along   **
************************************************/
function loggit(l){
  var log = "*****************************************\n"+
            " - "+l+"\n"+
            "*****************************************\n"
  console.log( chalk.cyan(log) );
}

function errorLog(er){
  var log = "*****************************************\n"+
            "**          CATASTROPHIC ERROR!        **\n"+
            "**                                     **\n"+
            "**       User attempted to use the     **\n"+
            "**     program in the manner it was    **\n"+
            "**          intended to be used!       **\n"+
            "**                                     **\n"+
            "              ERROR MESSAGE:             \n"+
            " - "+er+"\n"+
            "*****************************************\n";

  console.log( chalk.red( log )  );
}

function timePlz(){

  var D  = new Date(),
      h  = D.getHours(),
      m  = D.getMinutes(),
      s  = D.getSeconds(),
      dt = D.getDate(),
      yr = D.getFullYear(),
      months = [
        "January",
        "February",
        "March",
        "April",
        "May",
        "June",
        "July",
        "August",
        "September",
        "October",
        "November",
        "December"
      ],
      mt = months[D.getMonth()];

      //  convert to 12 hour time
      if(h > 12){ h = h - 12 };
      if(h === 0){ h = 12 };

      //  in case seconds is lower than 10
      if( s < 10 ){ s = '0' + s }

      return mt + ' ' + dt + ', ' + yr + ' at ' + h + ':' + m + ':' + s;

}
<|endoftext|>


<commit_before>'use strict';

var gulp   = require('gulp');
var plugins = require('gulp-load-plugins')();

var paths = {
  lint: ['./gulpfile.js', './lib/**/*.js'],
  watch: ['./gulpfile.js', './lib/**', './test/**/*.js', '!test/{temp,temp/**}'],
  tests: ['./test/**/*.js', '!test/{temp,temp/**}']<% if (istanbulModule) { %>,
  source: ['./lib/*.js']<% } %>
};

gulp.task('lint', function () {
  return gulp.src(paths.lint)
    .pipe(plugins.jshint('.jshintrc'))<% if (jscsModule) { %>
    .pipe(plugins.jscs())<% } %>
    .pipe(plugins.jshint.reporter('jshint-stylish'));
});<% if (istanbulModule) { %>

gulp.task('istanbul', function (cb) {
  gulp.src(paths.source)
    .pipe(plugins.istanbul()) // Covering files
    .on('end', function () {
      gulp.src(paths.tests, {cwd: __dirname})
        .pipe(plugins.mocha())
        .pipe(plugins.istanbul.writeReports()) // Creating the reports after tests runned
        .on('end', cb);
    });
});<% } else { %>

gulp.task('mocha', function () {
  gulp.src(paths.tests, {cwd: __dirname})
    .pipe(mocha({ reporter: 'list' }));
});<% } %><% if (releaseModule) { %>

gulp.task('bump', ['test'], function () {
  var bumpType = process.env.BUMP || 'patch'; // major.minor.patch

  return gulp.src(['./package.json'])
    .pipe(plugins.bump({ type: bumpType }))
    .pipe(gulp.dest('./'));
});<% } %>

gulp.task('watch', function () {
  gulp.run('test');
  gulp.watch(paths.watch, ['test']);
});

gulp.task('default', ['test']);
gulp.task('test', ['lint', <% if (istanbulModule) { %>'istanbul'<% } else { %>'mocha'<% } %>]);
<% if (releaseModule) { %>gulp.task('release', ['bump']);<% } %>
<commit_msg>Update _gulpfile.js<commit_after>'use strict';

var gulp   = require('gulp');
var plugins = require('gulp-load-plugins')();

var paths = {
  lint: ['./gulpfile.js', './lib/**/*.js'],
  watch: ['./gulpfile.js', './lib/**', './test/**/*.js', '!test/{temp,temp/**}'],
  tests: ['./test/**/*.js', '!test/{temp,temp/**}']<% if (istanbulModule) { %>,
  source: ['./lib/*.js']<% } %>
};

gulp.task('lint', function () {
  return gulp.src(paths.lint)
    .pipe(plugins.jshint('.jshintrc'))<% if (jscsModule) { %>
    .pipe(plugins.jscs())<% } %>
    .pipe(plugins.jshint.reporter('jshint-stylish'));
});<% if (istanbulModule) { %>

gulp.task('istanbul', function (cb) {
  gulp.src(paths.source)
    .pipe(plugins.istanbul()) // Covering files
    .on('finish', function () {
      gulp.src(paths.tests, {cwd: __dirname})
        .pipe(plugins.mocha())
        .pipe(plugins.istanbul.writeReports()) // Creating the reports after tests runned
        .on('end', cb);
    });
});<% } else { %>

gulp.task('mocha', function () {
  gulp.src(paths.tests, {cwd: __dirname})
    .pipe(mocha({ reporter: 'list' }));
});<% } %><% if (releaseModule) { %>

gulp.task('bump', ['test'], function () {
  var bumpType = process.env.BUMP || 'patch'; // major.minor.patch

  return gulp.src(['./package.json'])
    .pipe(plugins.bump({ type: bumpType }))
    .pipe(gulp.dest('./'));
});<% } %>

gulp.task('watch', function () {
  gulp.run('test');
  gulp.watch(paths.watch, ['test']);
});

gulp.task('default', ['test']);
gulp.task('test', ['lint', <% if (istanbulModule) { %>'istanbul'<% } else { %>'mocha'<% } %>]);
<% if (releaseModule) { %>gulp.task('release', ['bump']);<% } %>
<|endoftext|>