Skip to content

Commit 99cca0b

Browse files
committed
Add build step, see readme for instructions. Fixes #8
1 parent 1f9e9cd commit 99cca0b

13 files changed

+113
-43
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,7 @@ pip-log.txt
163163
.DS_Store
164164

165165
# web server
166-
server/
166+
server/
167+
168+
# node modules
169+
node_modules/

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "test/mocha/mocha-phantomjs"]
2-
path = test/mocha/mocha-phantomjs
3-
url = https://github.com/metaskills/mocha-phantomjs.git

MIT-LICENSE.txt

+19-19
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
Copyright 2012 Christoffer Åström, Andrée Hansson
2-
3-
Permission is hereby granted, free of charge, to any person obtaining
4-
a copy of this software and associated documentation files (the
5-
"Software"), to deal in the Software without restriction, including
6-
without limitation the rights to use, copy, modify, merge, publish,
7-
distribute, sublicense, and/or sell copies of the Software, and to
8-
permit persons to whom the Software is furnished to do so, subject to
9-
the following conditions:
10-
11-
The above copyright notice and this permission notice shall be
12-
included in all copies or substantial portions of the Software.
13-
14-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1+
Copyright 2012 Christoffer Åström, Andrée Hansson
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2020
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

grunt.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*global module:false*/
2+
module.exports = function(grunt) {
3+
4+
// Project configuration.
5+
grunt.initConfig({
6+
meta: {
7+
version: '0.1.0pre',
8+
banner: '/*! Touché - v<%= meta.version %> - ' +
9+
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
10+
'* https://github.com/stoffeastrom/touche/\n' +
11+
'* Copyright (c) <%= grunt.template.today("yyyy") %> ' +
12+
'Christoffer Åström, Andrée Hansson; Licensed MIT */'
13+
},
14+
lint: {
15+
files: ['grunt.js', 'lib/**/*.js', 'test/*.js']
16+
},
17+
mocha: {
18+
all: {
19+
src: ['test/index.html'],
20+
run: true
21+
}
22+
},
23+
concat: {
24+
dist: {
25+
src: [
26+
'<banner:meta.banner>',
27+
'lib/touche.js',
28+
'lib/*.js'
29+
],
30+
dest: 'dist/touche.js'
31+
}
32+
},
33+
min: {
34+
dist: {
35+
src: ['<banner:meta.banner>', '<config:concat.dist.dest>'],
36+
dest: 'dist/touche.min.js'
37+
}
38+
},
39+
watch: {
40+
files: '<config:lint.files>',
41+
tasks: 'lint'
42+
},
43+
jshint: {
44+
options: {
45+
curly: true,
46+
eqeqeq: true,
47+
immed: true,
48+
latedef: true,
49+
newcap: true,
50+
noarg: true,
51+
sub: true,
52+
undef: true,
53+
boss: true,
54+
eqnull: true,
55+
browser: true
56+
},
57+
globals: {}
58+
},
59+
uglify: {}
60+
});
61+
62+
grunt.loadNpmTasks('grunt-mocha');
63+
64+
// Default task.
65+
grunt.registerTask('default', 'lint mocha concat min');
66+
};

lib/touche.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121

2222
T.utils = {
2323
logger: function(event, touchList) {
24-
if(!event.touches) return;
24+
if(!event.touches) {
25+
return;
26+
}
27+
2528
touchList = touchList || 'touches';
2629

2730
var str = "",

readme.md

+16-11
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,24 @@ Touche.pinch(element, {
114114
});
115115
```
116116

117-
## How to run the test
117+
## Setting up the build environment
118118

119-
You can run the test by either running them in the browser (by opening `test.index.html`) or by command line.
120-
To set up running them from command line, read below.
119+
Touché is using grunt.js to build (concatenate + minify) and running tests. Below is instructions on how to properly set up this project.
121120

122121
```
123-
$ git submodule foreach git pull
122+
$ cd touche
123+
$ npm install -g grunt
124124
$ npm install -g phantomjs
125-
$ cd test/mocha/mocha-phantomjs
126-
$ npm install
127-
$ cd ../../cli
128-
// *nix:
129-
$ sh run-tests.sh
130-
// windows:
131-
$ run-tests.bat
125+
$ npm install grunt-mocha
126+
```
127+
128+
After installing, you can run a few different tasks using grunt:
129+
130+
```
131+
// lint all test + lib files
132+
$ grunt lint
133+
// run the test suite
134+
$ grunt mocha
135+
// default: runs lint, mocha, concat, min
136+
$ grunt
132137
```

test/cli/run-tests.bat

-1
This file was deleted.

test/cli/run-tests.sh

-2
This file was deleted.

test/index.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
<script src="test.utils.js"></script>
1515
<script src="test.point.js"></script>
1616
<script src="test.rect.js"></script>
17-
<script>
18-
if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
19-
else { mocha.run(); }
20-
</script>
17+
<script>mocha.run();</script>
2118
</body>
2219
</html>

test/mocha/mocha-phantomjs

-1
This file was deleted.

test/test.point.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*global describe, Touche, expect, it*/
12
describe('Point', function() {
23
var p1 = new Touche.Point(4, 10),
34
p2 = new Touche.Point(6, 20);

test/test.rect.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*global describe, Touche, expect, it*/
12
describe('Rect', function() {
23
var r = new Touche.Rect(4, 8, 100, 50),
34
p1 = new Touche.Point(30, 40),

test/test.utils.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/*global describe, Touche, expect, it*/
12
describe('Utils', function() {
23
describe('#isFunction', function() {
34
var isFn = Touche.utils.isFunction;

0 commit comments

Comments
 (0)