Skip to content

Commit e2007ca

Browse files
committed
Add Gruntfile.js
1 parent 1f0b9c4 commit e2007ca

File tree

6 files changed

+101
-30
lines changed

6 files changed

+101
-30
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* text=auto
1+
* text=auto

.gitignore

+17-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
.DS_Store
1+
# Coverage reports
2+
coverage
3+
4+
# Installed npm modules
5+
node_modules
6+
7+
# Folder view configuration files
8+
.DS_Store
9+
Desktop.ini
10+
11+
# Thumbnail cache files
12+
._*
13+
Thumbs.db
14+
15+
# Files that might appear on external disks
16+
.Spotlight-V100
17+
.Trashes

Gruntfile.js

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
module.exports = function(grunt) {
2+
3+
var commandOptions = {
4+
'stdout': true,
5+
'stderr': true,
6+
'failOnError': true
7+
};
8+
9+
grunt.initConfig({
10+
'meta': {
11+
'testFile': 'tests/tests.js'
12+
},
13+
'uglify': {
14+
'dist': {
15+
'options': {
16+
'report': 'gzip',
17+
'preserveComments': 'some'
18+
},
19+
'files': {
20+
'punycode.min.js': ['punycode.js']
21+
}
22+
}
23+
},
24+
'shell': {
25+
'cover': {
26+
'command': 'istanbul cover --report "html" --verbose --dir "coverage" "<%= meta.testFile %>"',
27+
'options': commandOptions
28+
},
29+
// Rhino 1.7R4 has a bug that makes it impossible to test punycode.
30+
// https://bugzilla.mozilla.org/show_bug.cgi?id=775566
31+
// To test, use Rhino 1.7R3, or wait (heh) for the 1.7R5 release.
32+
'test-rhino': {
33+
'command': 'echo "Testing in Rhino..."; rhino -opt -1 "tests.js"',
34+
'options': {
35+
'stdout': true,
36+
'stderr': true,
37+
'failOnError': true,
38+
'execOptions': {
39+
'cwd': 'tests'
40+
}
41+
}
42+
},
43+
'test-ringo': {
44+
'command': 'echo "Testing in Ringo..."; ringo -o -1 "<%= meta.testFile %>"',
45+
'options': commandOptions
46+
},
47+
'test-narwhal': {
48+
'command': 'echo "Testing in Narwhal..."; export NARWHAL_OPTIMIZATION=-1; narwhal "<%= meta.testFile %>"',
49+
'options': commandOptions
50+
},
51+
'test-node': {
52+
'command': 'echo "Testing in Node..."; node "<%= meta.testFile %>"',
53+
'options': commandOptions
54+
},
55+
'test-browser': {
56+
'command': 'echo "Testing in a browser..."; open "tests/index.html"',
57+
'options': commandOptions
58+
}
59+
}
60+
});
61+
62+
grunt.loadNpmTasks('grunt-shell');
63+
grunt.loadNpmTasks('grunt-contrib-uglify');
64+
65+
grunt.registerTask('cover', 'shell:cover');
66+
grunt.registerTask('test', [
67+
'shell:test-rhino',
68+
'shell:test-ringo',
69+
'shell:test-narwhal',
70+
'shell:test-node',
71+
'shell:test-browser'
72+
]);
73+
74+
grunt.registerTask('default', ['test', 'cover']);
75+
76+
};

README.md

+6-16
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ require(
5757
Usage example:
5858

5959
~~~js
60-
6160
// encode/decode domain names
6261
punycode.toASCII('mañana.com'); // 'xn--maana-pta.com'
6362
punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com'
@@ -73,24 +72,15 @@ punycode.decode('--dqo34k'); // '☃-⌘'
7372

7473
[Full API documentation is available.](https://github.com/bestiejs/punycode.js/tree/master/docs#readme)
7574

76-
## Cloning this repo
77-
78-
To clone this repository including all submodules, using Git 1.6.5 or later:
75+
Feel free to fork if you see possible improvements!
7976

80-
~~~ bash
81-
git clone --recursive https://github.com/bestiejs/punycode.js.git
82-
cd punycode.js
83-
~~~
77+
## Unit tests & code coverage
8478

85-
For older Git versions, just use:
79+
After cloning this repository, run `npm install --dev` to install the dependencies needed for Punycode.js development and testing. You may want to install Istanbul _globally_ using `npm install istanbul -g`.
8680

87-
~~~ bash
88-
git clone https://github.com/bestiejs/punycode.js.git
89-
cd punycode.js
90-
git submodule update --init
91-
~~~
81+
Once that’s done, you can run the unit tests in Node using `npm test` or `node tests/tests.js`. To run the tests in Rhino, Ringo, Narwhal, and web browsers as well, use `grunt test`.
9282

93-
Feel free to fork if you see possible improvements!
83+
To generate the code coverage report, use `grunt cover`.
9484

9585
## Authors
9686

@@ -104,4 +94,4 @@ Feel free to fork if you see possible improvements!
10494

10595
## License
10696

107-
Punycode.js is dual licensed under the [MIT](http://mths.be/mit) and [GPL](http://mths.be/gpl) licenses.
97+
Punycode.js is dual licensed under the [MIT](http://mths.be/mit) and [GPL](http://mths.be/gpl) licenses.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"devDependencies": {
6060
"istanbul": "~0.1.33",
6161
"grunt": "~0.4.1",
62+
"grunt-contrib-uglify": "~0.2.0",
6263
"grunt-shell": "~0.2.1",
6364
"qunitjs": "~1.11.0",
6465
"qunit-clib": "~1.3.0",

tests/run-tests.sh

-12
This file was deleted.

0 commit comments

Comments
 (0)