|
| 1 | +/* global module:false */ |
| 2 | +module.exports = function(grunt){ |
| 3 | + // Project configuration. |
| 4 | + var saucekey = null; |
| 5 | + if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_SECURE_ENV_VARS) { |
| 6 | + saucekey = process.env.saucekey; |
| 7 | + } |
| 8 | + grunt.initConfig({ |
| 9 | + pkg: '<json:package.json>', |
| 10 | + meta: { |
| 11 | + banner: '/*! <%= pkg.name %> */' |
| 12 | + }, |
| 13 | + lint: { |
| 14 | + files: ['grunt.js', 'src/**/*.js', 'test/**/*.js'] |
| 15 | + }, |
| 16 | + |
| 17 | + server: { |
| 18 | + base: '.', |
| 19 | + port: 9999 |
| 20 | + }, |
| 21 | + |
| 22 | + qunit: { |
| 23 | + all: ['http://localhost:9999/test/index.html'] |
| 24 | + }, |
| 25 | + |
| 26 | + 'saucelabs-qunit': { |
| 27 | + all: { |
| 28 | + username: 'indexeddbshim', |
| 29 | + key: saucekey, |
| 30 | + testname: 'jquery-indexeddb', |
| 31 | + tags: ['master'], |
| 32 | + urls: ['http://127.0.0.1:9999/test/index.html'], |
| 33 | + browsers: [{ |
| 34 | + browserName: 'firefox' |
| 35 | + }, { |
| 36 | + browserName: 'chrome' |
| 37 | + }] |
| 38 | + } |
| 39 | + }, |
| 40 | + |
| 41 | + jshint: { |
| 42 | + options: { |
| 43 | + camelcase: true, |
| 44 | + nonew: true, |
| 45 | + curly: true,// require { } |
| 46 | + eqeqeq: true,// === instead of == |
| 47 | + immed: true,// wrap IIFE in parentheses |
| 48 | + latedef: true,// variable declared before usage |
| 49 | + newcap: true,// capitalize class names |
| 50 | + undef: true,// checks for undefined variables |
| 51 | + regexp: true, |
| 52 | + evil: true, |
| 53 | + eqnull: true,// == allowed for undefined/null checking |
| 54 | + expr: true,// allow foo && foo() |
| 55 | + browser: true |
| 56 | + // browser environment |
| 57 | + }, |
| 58 | + globals: { |
| 59 | + DEBUG: true, |
| 60 | + console: true, |
| 61 | + require: true, |
| 62 | + |
| 63 | + // Tests. |
| 64 | + _: true, |
| 65 | + asyncTest: true, |
| 66 | + DB: true, |
| 67 | + dbVersion: true, |
| 68 | + deepEqual: true, |
| 69 | + equal: true, |
| 70 | + expect: true, |
| 71 | + fail: true, |
| 72 | + module: true, |
| 73 | + nextTest: true, |
| 74 | + notEqual: true, |
| 75 | + ok: true, |
| 76 | + sample: true, |
| 77 | + start: true, |
| 78 | + stop: true, |
| 79 | + queuedAsyncTest: true, |
| 80 | + queuedModule: true, |
| 81 | + unescape: true, |
| 82 | + process: true |
| 83 | + } |
| 84 | + }, |
| 85 | + uglify: {} |
| 86 | + }); |
| 87 | + |
| 88 | + // Default task. |
| 89 | + grunt.loadNpmTasks('grunt-saucelabs-qunit'); |
| 90 | + grunt.registerTask('build', 'lint'); |
| 91 | + |
| 92 | + grunt.registerTask("publish", function(){ |
| 93 | + var done = this.async(); |
| 94 | + console.log("Running publish action"); |
| 95 | + var request = require("request"); |
| 96 | + request("https://api.travis-ci.org/repos/axemclion/jquery-indexeddb/builds.json", function(err, res, body){ |
| 97 | + var commit = JSON.parse(body)[0]; |
| 98 | + var commitMessage = ["Commit from Travis Build #", commit.number, "\nBuild - https://travis-ci.org/axemclion/jquery-indexeddb/builds/", commit.id, "\nBranch : ", commit.branch, "@ ", commit.commit]; |
| 99 | + console.log("Got Travis Build details"); |
| 100 | + request({ |
| 101 | + url: "https://api.github.com/repos/axemclion/jquery-indexeddb/merges?access_token=" + process.env.githubtoken, |
| 102 | + method: "POST", |
| 103 | + body: JSON.stringify({ |
| 104 | + "base": "gh-pages", |
| 105 | + "head": "master", |
| 106 | + "commit_message": commitMessage.join("") |
| 107 | + }) |
| 108 | + }, function(err, response, body){ |
| 109 | + console.log(body); |
| 110 | + done(!err); |
| 111 | + }); |
| 112 | + }); |
| 113 | + }); |
| 114 | + |
| 115 | + var testJobs = ["build", "server"]; |
| 116 | + if (saucekey !== null) { |
| 117 | + testJobs.push("saucelabs-qunit"); |
| 118 | + } |
| 119 | + if (process.env.CI && process.env.TRAVIS) { |
| 120 | + testJobs.push("publish"); |
| 121 | + } |
| 122 | + |
| 123 | + grunt.registerTask('test', testJobs.join(" ")); |
| 124 | + |
| 125 | + grunt.registerTask('default', 'build'); |
| 126 | +}; |
0 commit comments