Skip to content

Commit

Permalink
Merge pull request #45 from LomaxRx/master
Browse files Browse the repository at this point in the history
changed scope of d4 var to work with how browserify compiles
  • Loading branch information
heavysixer committed Mar 29, 2016
2 parents 529aff2 + de78db4 commit 5741483
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 38 deletions.
11 changes: 10 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ module.exports = function(grunt) {
}
}
},
browserify: {
specs: {
src: ["test/tests/browserify-test.js"],
dest: "test/tests/d4-bundle.js",
options: {
}
}
},
mocha: {
options: {
run: true,
Expand Down Expand Up @@ -124,8 +132,9 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-mocha');
grunt.loadNpmTasks('grunt-plato');
grunt.loadNpmTasks('grunt-remove-logging');
grunt.loadNpmTasks('grunt-browserify');

grunt.registerTask('test', ['concat', 'mocha']);
grunt.registerTask('test', ['concat', 'browserify', 'mocha']);
grunt.registerTask('quality', ['plato']);
grunt.registerTask('default', ['jsbeautifier', 'jshint', 'test']);
grunt.registerTask('release', ['default', 'concat', 'uglify', 'removelogging']);
Expand Down
9 changes: 6 additions & 3 deletions d4.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! d4 - v0.9.5
/*! d4 - v0.9.6
* License: MIT Expat
* Date: 2016-03-10
* Date: 2016-03-28
* Copyright: Mark Daggett, D4 Team
*/
/*!
Expand All @@ -9,14 +9,17 @@
(c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
Underscore may be freely distributed under the MIT license.
*/

var d4;

(function() {
'use strict';

var root = this;
var breaker = {};

// Create a safe reference to the d4 object.
var d4 = function(obj) {
d4 = function(obj) {
if (obj instanceof d4) {
return obj;
}
Expand Down
66 changes: 33 additions & 33 deletions d4.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"chai": "~1.9.0",
"chai-spies": "~0.5.1",
"grunt": "~0.4.0",
"grunt-browserify": "^5.0.0",
"grunt-cli": "~0.1.11",
"grunt-contrib-concat": "~0.1.3",
"grunt-contrib-jshint": "~0.1.1",
Expand Down
5 changes: 4 additions & 1 deletion src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
(c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
Underscore may be freely distributed under the MIT license.
*/

var d4;

(function() {
'use strict';

var root = this;
var breaker = {};

// Create a safe reference to the d4 object.
var d4 = function(obj) {
d4 = function(obj) {
if (obj instanceof d4) {
return obj;
}
Expand Down
1 change: 1 addition & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<link href="lib/mocha.css" rel="stylesheet"></link>
<title>d4 test suite</title>
<script src="../bower_components/d3/d3.js"></script>
<script src="tests/d4-bundle.js"></script>
<script src="lib/d4.js"></script>
<script src="tests/axis-tests.js"></script>
<script src="tests/base-test.js"></script>
Expand Down
13 changes: 13 additions & 0 deletions test/tests/browserify-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*global describe:true*/
/*global it:true*/
/*global beforeEach:true*/
/*global document:true*/

'use strict';

describe( 'using browserify', function(){
it('should compile d4 with require', function() {
var d4 = require( '../lib/d4.js' );
expect(d4).to.not.be.an('undefined');
});
});

0 comments on commit 5741483

Please sign in to comment.