Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builds with Grunt Browserify. #31

Merged
merged 2 commits into from
May 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ module.exports = ->
@registerTask "test", [
"jshint"
"jscs"
"browserify"
"simplemocha"
"karma:run"
"karma:source"
"karma:modern"
"karma:legacy"
]

@registerTask "default", [
"jshint"
"jscs"
"karma:daemon"
"test"
"karma:watch"
]
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,15 @@ Run the tests inside the Node runtime and within PhantomJS:
grunt test
```

This will run the tests against the AMD source, the built modern
dist/combyne.js, and the built legacy dist/combyne.legacy.js files.

### Continuous testing ###

To keep the PhantomJS tests running continuously, run:

``` bash
grunt karma:daemon
grunt karma:watch
```

The tests will automatically run whenever files change.
Expand Down
20 changes: 20 additions & 0 deletions build/tasks/browserify.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = ->
@loadNpmTasks "grunt-browserify"

@config "browserify",
options:
transform: ["deamdify"]

bundleOptions:
standalone: "combyne"

modern:
options:
"ignore": ["lib/support/**/*.js"]

files:
"dist/combyne.js": ["lib/index.js"]

legacy:
files:
"dist/combyne.legacy.js": ["lib/index.js"]
39 changes: 37 additions & 2 deletions build/tasks/karma.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ module.exports = ->
preprocessors:
"lib/!(support).js": "coverage"
"lib/!(support)/**/*.js": "coverage"
"dist/*.js": "coverage"

coverageReporter:
type: "lcov"
Expand All @@ -72,14 +73,48 @@ module.exports = ->
{ pattern: "test/tests/**/*.js", included: false }
]

daemon:
watch:
options:
singleRun: false

run:
source:
options:
singleRun: true

modern:
options:
singleRun: true

files: [
"bower_components/assert/assert.js"
"bower_components/json3/lib/json3.js"
"bower_components/requirejs/require.js"
"test/set-modern.js"
"test/runner.js"

{ pattern: "dist/combyne.js", included: false }
{ pattern: "lib/**/*.*", included: false }
{ pattern: "bower_components/**/*.*", included: false }
{ pattern: "test/tests/**/*.js", included: false }
]

legacy:
options:
singleRun: true

files: [
"bower_components/assert/assert.js"
"bower_components/json3/lib/json3.js"
"bower_components/requirejs/require.js"
"test/set-legacy.js"
"test/runner.js"

{ pattern: "dist/combyne.legacy.js", included: false }
{ pattern: "lib/**/*.*", included: false }
{ pattern: "bower_components/**/*.*", included: false }
{ pattern: "test/tests/**/*.js", included: false }
]

saucelabs:
options:
captureTimeout: 120000
Expand Down
20 changes: 9 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,23 @@
"main": "dist/combyne.js",
"devDependencies": {
"amdefine": "~0.1.0",
"grunt": "~0.4.4",
"grunt-jscs-checker": "~0.4.1",
"browserify": "^4.1.5",
"deamdify": "~0.1.1",
"grunt": "~0.4.5",
"grunt-browserify": "~2.1.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-simple-mocha": "~0.4.0",
"grunt-jscs-checker": "~0.4.1",
"grunt-karma": "~0.8.2",
"grunt-karma-coveralls": "~2.4.4",
"karma-mocha": "~0.1.0",
"grunt-simple-mocha": "~0.4.0",
"jsdoc": "~3.3.0-alpha5",
"karma-coverage": "~0.2.1",
"karma-mocha": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.4",
"jsdoc": "~3.3.0-alpha5",
"browserify": "~3.46.0",
"deamdify": "~0.1.1",
"karma-sauce-launcher": "~0.2.8"
},
"scripts": {
"test": "grunt test coveralls",
"doc": "jsdoc -r -d docs/ lib/ README.md",
"build": "npm run modern && npm run legacy",
"modern": "browserify --ignore=./lib/support/**/*.js -g deamdify lib -s combyne > dist/combyne.js",
"legacy": "browserify -g deamdify lib -s combyne > dist/combyne.legacy.js"
"doc": "jsdoc -r -d docs/ lib/ README.md"
}
}
10 changes: 8 additions & 2 deletions test/runner.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function(window) {
"use strict";
"use strict";

// The Karma object.
var karma = window.__karma__;
Expand Down Expand Up @@ -40,7 +40,13 @@
mocha.setup("bdd");

// Modify the configuration to point to the correct source base.
require.config({ baseUrl: baseUrl });
require.config({
baseUrl: baseUrl,
paths: {
// Toggle the path to use a distribution or the source.
"../../lib/index": window.useDist || "../../lib/index"
}
});

// Load all tests and start Karma.
require(tests, karma ? karma.start : function() { mocha.run(); });
Expand Down
5 changes: 5 additions & 0 deletions test/set-legacy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(function(window) {
"use strict";

window.useDist = "../../dist/combyne.legacy";
})(this);
5 changes: 5 additions & 0 deletions test/set-modern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(function(window) {
"use strict";

window.useDist = "../../dist/combyne";
})(this);