/* This file has been generated by ox-ui-module generator.
 * Please only apply minor changes (better no changes at all) to this file
 * if you want to be able to run the generator again without much trouble.
 *
 * If you really have to change this file for whatever reason, try to contact
 * the core team and describe your use-case. May be, your changes can be
 * integrated into the templates to be of use for everybody.
 */
'use strict';

module.exports = function (grunt) {

    grunt.config.extend('watch', {

        options: {
            interval: 500,
            interrupt: true,
            debounceDelay: 500
        },
        manifests: {
            files: 'apps/**/manifest.json',
            tasks: ['manifests', 'force_update'],
            options: { livereload: true }
        },
        karma: {
            files: ['spec/**/*.js'],
            tasks: ['newer:jshint:specs', 'newer:copy:specs', 'karma:unit:run']
        },
        configs: {
            options: { reload: true },
            files: [
                'Gruntfile.js',
                'grunt/tasks/*.js'
            ],
            tasks: ['default']
        },
        all: {
            files: [
                'apps/**/*.{js,less}',
                'src/*',
                'lib/**/*.js',
                'bower.json',
                'package.json'
            ],
            tasks: ['default', 'karma:unit:run'],
            options: { livereload: true }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-watch');
};

/* This file has been generated by ox-ui-module generator.
 * Please only apply minor changes (better no changes at all) to this file
 * if you want to be able to run the generator again without much trouble.
 *
 * If you really have to change this file for whatever reason, try to contact
 * the core team and describe your use-case. May be, your changes can be
 * integrated into the templates to be of use for everybody.
 */
'use strict';

module.exports = function (grunt) {

    var livereloadConfig = (function () {
        var conf = grunt.config().local.appserver;
        if (conf && conf.protocol === 'https') {
            return {
                key: grunt.file.read('node_modules/grunt-contrib-connect/tasks/certs/server.key'),
                cert: grunt.file.read('node_modules/grunt-contrib-connect/tasks/certs/server.crt')
            };
        } else {
            return true;
        }
    }());

    grunt.config.extend('watch', {

        options: {
            interval: 500,
            interrupt: true,
            debounceDelay: 500
        },
        manifests: {
            files: 'apps/**/manifest.json',
            tasks: ['manifests', 'force_update'],
            options: { livereload: livereloadConfig }
        },
        karma: {
            files: ['spec/**/*.js'],
            tasks: ['newer:jshint:specs', 'newer:copy:specs', 'karma:unit:run']
        },
        configs: {
            options: { reload: true },
            files: [
                'Gruntfile.js',
                'grunt/tasks/*.js'
            ],
            tasks: ['default']
        },
        all: {
            files: [
                'apps/**/*.{js,less}',
                'src/*',
                'lib/**/*.js',
                'bower.json',
                'package.json'
            ],
            tasks: ['default', 'karma:unit:run'],
            options: { livereload: livereloadConfig }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-watch');
};

fix livereload with new https setting