namespace :build do

    desc 'Run BlankketJS test coverage'
    task :coverage do
        `mocha -r blanket -R html-cov > public/blanket.html test/mocha/`
    end

    desc 'Run mocha tests'
    task :mocha_test do
        `gulp test`
    end

    desc 'Clear node cache'
    task :clear_cache do
        `npm cache clean`
    end

    desc 'Install all local npm modules'
    task :npm_install_local do
        `npm i`
    end

    desc 'Install all local global modules'
    task :npm_install_global do
        `npm install jshint@2.4.2 -g`
        `npm install gulp@3.6.2 -g`
        `npm install mocha@1.17.1 -g`
        `npm install casperjs@1.1.0-beta3 -g`
        `npm install phantomjs@1.9.7-3 -g`
        `npm install docco@0.6.3 -g`
    end

    desc 'Make public folders'
    task :mk_public_folders do
        `mkdir -p ./public/js`
        `mkdir -p ./public/js/dev`
        `mkdir -p ./public/js/releases`
    end

    task :config do
        if !File.exists? './config/config.json'
            `cp ./config/config.shadow.json ./config/config.json`
        end
    end

    desc 'Run a full build'
    task :all => [:config, :mk_public_folders, :clear_cache, :npm_install_global, :npm_install_local, :mocha_test]

end

namespace :jenkins do

    desc 'Output python'
    task :python do
        puts `npm config set python python2.7`
        puts `npm config get python`
    end

    desc 'Remove all globally installed npm modules'
    task :npm_remove_global do
        `npm remove jshint gulp mocha casperjs phantomjs docco -g`
    end

    desc 'Export mocha tests to XUnit'
    task :mocha_test do
         `mkdir -p ./test/mocha/reports`
         `mocha -R xunit test/mocha/ > test/mocha/reports/mocha-report.xml`
    end

    desc 'Run a full build for jenkins'
    task :all => [:python, :npm_remove_global, 'build:config', 'build:clear_cache', 'build:npm_install_global', 'build:npm_install_local', :mocha_test]

end