Skip to content

Commit

Permalink
adding amd support; fixes #24 and #25
Browse files Browse the repository at this point in the history
  • Loading branch information
travis-ci committed Feb 6, 2016
1 parent ddb6fae commit cf97096
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"strict": true,
"undef": true,
"unused": true,
"globals": {
"define": true
},
"-W008": false, // ignore leading decimal
"-W030": false // allow expression assignments
}
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ module.exports = function(grunt) {

require('matchdep').filterAll('grunt-*').forEach(grunt.loadNpmTasks);

grunt.registerTask('default', ['jshint', 'mochaTest', 'closureCompiler', 'concat', 'sync']);
grunt.registerTask('build', ['closureCompiler', 'concat', 'sync']);
grunt.registerTask('default', ['jshint', 'mochaTest', 'build']);

};
12 changes: 6 additions & 6 deletions currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
that.value = that.intValue / 100;
};

// currency.js version
currency.version = '0.4.0';

// Default options
var settings = currency.settings = {
symbol: '$'
Expand Down Expand Up @@ -136,10 +133,13 @@

};

if (!global && typeof module === 'object' && typeof module.exports === 'object') {
/* istanbul ignore next */
if(typeof define === 'function' && define.amd) {
define([], function() { return currency; });
} else if (typeof module === 'object' && typeof module.exports === 'object') {
module.exports = currency;
} else if (global) {
} else {
global.currency = currency;
}

})(typeof window !== 'undefined' ? window : undefined);
})(this);
6 changes: 3 additions & 3 deletions currency.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"scripts": {
"test": "node_modules/.bin/mocha test",
"coverage": "node_modules/.bin/istanbul cover --dir ./reports node_modules/.bin/_mocha test"
"coverage": "node_modules/.bin/istanbul cover --dir ./reports node_modules/.bin/_mocha test",
"prepublish": "grunt build"
},
"repository": {
"type": "git",
Expand Down
11 changes: 0 additions & 11 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@ var assert = require('assert')

describe('currency.js', function() {

it('should attach to window', function() {
delete require.cache[require.resolve('../currency.js')];
global.window = {};
require('../currency.js');
assert.ok(typeof global.window.currency !== 'undefined', 'currency is attached to window');
assert.strictEqual(global.window.currency(1.23).value, 1.23, 'currency(1.23) is 1.23');
global.window = null;
delete require.cache[require.resolve('../currency.js')];
currency = require('../currency.js');
});

it('should be immutable', function() {
var value = currency(1),
/* jshint unused: false */
Expand Down

0 comments on commit cf97096

Please sign in to comment.