forked from indexeddbshim/IndexedDBShim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grunt.js
154 lines (143 loc) · 3.76 KB
/
grunt.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* global module:false */
module.exports = function(grunt){
var srcFiles = ['src/Init.js', 'src/util.js', 'src/Sca.js', 'src/Key.js', 'src/Event.js', 'src/IDBRequest.js', 'src/IDBKeyRange.js', 'src/IDBCursor.js', 'src/IDBIndex.js', 'src/IDBObjectStore.js', 'src/IDBTransaction.js', 'src/IDBDatabase.js', 'src/shimIndexedDB.js', 'src/globalVars.js'];
// Project configuration.
var saucekey = null;
if (typeof process.env.saucekey !== "undefined") {
saucekey = process.env.saucekey;
}
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: '/*! <%= pkg.name %> */'
},
lint: {
files: ['grunt.js', 'src/**/*.js', 'test/**/*.js']
},
concat: {
dist: {
src: srcFiles,
dest: 'dist/<%= pkg.name %>.js'
}
},
'jsmin-sourcemap': {
all: {
src: srcFiles,
dest: 'dist/<%= pkg.name %>.min.js',
srcRoot: '..'
}
},
watch: {
files: '<config:lint.files>',
tasks: 'lint test'
},
server: {
base: '.',
port: 9999
},
qunit: {
all: ['http://localhost:9999/test/index.html']
},
'saucelabs-qunit': {
all: {
username: 'indexeddbshim',
key: saucekey,
testname: 'IndexedDBShim',
tags: ['master'],
urls: ['http://127.0.0.1:9999/test/index.html'],
browsers: [{
browserName: 'safari',
platform: 'Windows 2008',
version: '5'
}, {
browserName: 'opera'
}]
}
},
jshint: {
options: {
camelcase: true,
nonew: true,
curly: true,// require { }
eqeqeq: true,// === instead of ==
immed: true,// wrap IIFE in parentheses
latedef: true,// variable declared before usage
newcap: true,// capitalize class names
undef: true,// checks for undefined variables
regexp: true,
evil: true,
eqnull: true,// == allowed for undefined/null checking
expr: true,// allow foo && foo()
browser: true
// browser environment
},
globals: {
// Shim.
DEBUG: true,
console: true,
DOMException: true,
IDBTransaction: true,
idbModules: true,
logger: true,
require: true,
// Tests.
_: true,
asyncTest: true,
DB: true,
dbVersion: true,
deepEqual: true,
equal: true,
expect: true,
fail: true,
module: true,
nextTest: true,
notEqual: true,
ok: true,
sample: true,
start: true,
stop: true,
queuedAsyncTest: true,
queuedModule: true,
unescape: true,
process: true
}
},
uglify: {}
});
// Default task.
grunt.loadNpmTasks('grunt-jsmin-sourcemap');
grunt.loadNpmTasks('grunt-saucelabs-qunit');
grunt.registerTask('build', 'lint concat jsmin-sourcemap');
grunt.registerTask("publish", function(){
var done = this.async();
console.log("Running publish action");
var request = require("request");
request("https://api.travis-ci.org/repos/axemclion/IndexedDBShim/builds.json", function(err, res, body){
var commit = JSON.parse(body)[0];
var commitMessage = ["Commit from Travis Build #", commit.number, "\nBuild - https://travis-ci.org/axemclion/IndexedDBShim/builds/", commit.id, "\nBranch : ", commit.branch, "@ ", commit.commit];
console.log("Got Travis Build details");
request({
url: "https://api.github.com/repos/axemclion/IndexedDBShim/merges?access_token=" + process.env.githubtoken,
method: "POST",
body: JSON.stringify({
"base": "gh-pages",
"head": "master",
"commit_message": commitMessage.join("")
})
}, function(err, response, body){
console.log(body);
done(!err);
});
});
});
var testJobs = ["build", "server"];
if (saucekey !== null) {
testJobs.push("saucelabs-qunit");
}
if (process.env.CI && process.env.TRAVIS) {
testJobs.push("publish");
}
testJobs.push("publish");
grunt.registerTask('test', testJobs.join(" "));
grunt.registerTask('default', 'build');
};