Skip to content

Commit 45fa585

Browse files
authored
Merge pull request #419 from adamwdraper/develop
2.0.2
2 parents 8c0760b + 257e852 commit 45fa585

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+1081
-2865
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@ Icon
2828
# --------------------
2929
node_modules/
3030
.sass-cache
31+
temp/

Diff for: Gruntfile.js

+92-58
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,48 @@
1-
var fs = require('fs');
2-
31
module.exports = function(grunt) {
42

5-
var minifiedFiles = {
6-
'min/numeral.min.js' : [
7-
'numeral.js'
8-
],
9-
'min/locales.min.js': [
10-
'locales.js'
11-
],
12-
'min/numeral-with-locales.min.js': [
13-
'numeral-with-locales.js'
14-
]
15-
};
3+
var compileType = function() {
4+
var type = this.data.type;
5+
var template = grunt.file.read('templates/types.js');
6+
var anon = grunt.file.read('templates/anon.js');
7+
var files = grunt.file.expand([
8+
'src/' + type + '/*.js'
9+
]);
10+
var regexp = /\}\(this, function \(numeral\) \{\s([\s\S]+)(?:\s\}\)\);)/;
11+
var content = '';
12+
var file;
13+
var i;
1614

17-
// all the lang files need to be added manually
18-
fs.readdirSync('./src/locales').forEach(function (path) {
19-
var file = path.slice(0, -3),
20-
destination = 'min/locales/' + file + '.min.js',
21-
src = ['src/locales/' + path];
15+
for (i = 0; i < files.length; i++) {
16+
file = grunt.file.read(files[i]);
2217

23-
minifiedFiles[destination] = src;
24-
});
18+
content += '\n' + grunt.template.process(anon, {
19+
data: {
20+
content: file.match(regexp)[1]
21+
}
22+
}) + '\n';
23+
}
24+
25+
grunt.file.write('temp/' + type + '.js', content);
26+
27+
if (type === 'locales') {
28+
grunt.file.write('locales.js', grunt.template.process(template, {
29+
data: {
30+
type: type,
31+
content: content
32+
}
33+
}));
34+
}
35+
},
36+
compileNumeral = function() {
37+
var regexp = /([\s])return numeral;(?:\s\}\)\);)/;
38+
var numeral = grunt.file.read('src/numeral.js');
39+
var formats = grunt.file.read('temp/formats.js');
40+
var index = numeral.indexOf('return numeral;');
41+
42+
numeral = numeral.substr(0, index) + '\n' + formats + numeral.substr(index);
43+
44+
grunt.file.write('numeral.js', numeral);
45+
};
2546

2647
grunt.initConfig({
2748
mochaTest : {
@@ -34,9 +55,8 @@ module.exports = function(grunt) {
3455
karma: {
3556
options: {
3657
files: [
37-
'src/numeral.js',
38-
'src/formats/*.js',
39-
'src/locales/*.js',
58+
'numeral.js',
59+
'locales.js',
4060
'tests/numeral.js',
4161
'tests/formats/*.js',
4262
'tests/locales/*.js'
@@ -58,35 +78,39 @@ module.exports = function(grunt) {
5878
configFile: 'karma-ci.conf.js'
5979
}
6080
},
61-
uglify: {
62-
my_target: {
63-
files: minifiedFiles
81+
compile: {
82+
locales: {
83+
type: 'locales'
6484
},
65-
options: {
66-
preserveComments: 'some'
85+
formats: {
86+
type: 'formats'
6787
}
6888
},
69-
concat: {
70-
numeral: {
71-
src: [
72-
'src/numeral.js',
73-
'src/formats/*.js'
74-
],
75-
dest: 'numeral.js'
76-
},
77-
locales: {
78-
src: [
79-
'src/locales/*.js'
80-
],
81-
dest: 'locales.js'
89+
uglify: {
90+
min: {
91+
files: [
92+
{
93+
expand: true,
94+
cwd: 'src/',
95+
src: [
96+
'locales/*.js'
97+
],
98+
dest: 'min/',
99+
ext: '.min.js'
100+
},
101+
{
102+
expand: true,
103+
src: [
104+
'numeral.js',
105+
'locales.js'
106+
],
107+
dest: 'min/',
108+
ext: '.min.js'
109+
}
110+
]
82111
},
83-
numeralWithLocales: {
84-
src: [
85-
'src/numeral.js',
86-
'src/formats/*.js',
87-
'src/locales/*.js'
88-
],
89-
dest: 'numeral-with-locales.js'
112+
options: {
113+
preserveComments: 'some'
90114
}
91115
},
92116
jshint: {
@@ -103,50 +127,60 @@ module.exports = function(grunt) {
103127
'eqnull': true,
104128
'newcap': true,
105129
'noarg': true,
106-
'onevar': true,
107130
'undef': true,
108131
'sub': true,
109132
'strict': false,
110-
'quotmark': 'single'
133+
'quotmark': 'single',
134+
'globals': {
135+
'define': true
136+
}
111137
}
112138
}
113139
});
114140

115141
grunt.loadNpmTasks('grunt-contrib-uglify');
116142
grunt.loadNpmTasks('grunt-contrib-jshint');
117-
grunt.loadNpmTasks('grunt-contrib-concat');
118143
grunt.loadNpmTasks('grunt-mocha-test');
119144
grunt.loadNpmTasks('grunt-karma');
120145

121146
grunt.registerTask('default', [
122147
'test'
123148
]);
124149

125-
grunt.registerTask('test', [
150+
grunt.registerMultiTask('compile', compileType);
151+
152+
grunt.registerTask('compile:numeral', compileNumeral);
153+
154+
grunt.registerTask('build', [
126155
'jshint',
156+
'compile',
157+
'compile:numeral'
158+
]);
159+
160+
grunt.registerTask('test', [
161+
'build',
127162
'mochaTest',
128163
'karma:local'
129164
]);
130165

131166
grunt.registerTask('test:npm', [
132-
'jshint',
167+
'build',
133168
'mochaTest'
134169
]);
135170

136171
grunt.registerTask('test:browser', [
137-
'jshint',
172+
'build',
138173
'karma:local'
139174
]);
140175

141-
// P
142-
grunt.registerTask('build', [
143-
'concat',
176+
grunt.registerTask('dist', [
177+
'build',
144178
'uglify'
145179
]);
146180

147181
// Travis CI task.
148182
grunt.registerTask('travis', [
149-
'jshint',
183+
'build',
150184
'mochaTest',
151185
'karma:ci'
152186
]);

Diff for: README.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.svg?branch
2121

2222
# Contributing
2323

24-
#### Important: Please create your branch from and submit pull requests to the `develop` branch.
24+
#### Important: Please create your branch from and submit pull requests to the `develop` branch. All pull requests must include the appropriate tests.
2525

2626
1. Fork the library
2727

@@ -35,11 +35,16 @@ Develop [![Build Status](https://travis-ci.org/adamwdraper/Numeral-js.svg?branch
3535

3636
6. To test your tests, run `grunt`
3737

38-
7. When all your tests are passing, run `grunt build` to minify all files
38+
7. When all your tests are passing, run `grunt dist` to compile and minify all files
3939

4040
8. Submit a pull request to the `develop` branch.
4141

4242

43+
### Formats
44+
45+
Formats now exist in their own files and act more or less as plugins. Check out the [bytes format](https://github.com/adamwdraper/Numeral-js/blob/master/src/formats/bytes.js) for an example of how to create one.
46+
47+
4348
### Locales
4449

4550
When naming locale files use the [ISO 639-1 language codes](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) supplemented by [ISO 3166-1](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) country codes when necessary.
@@ -51,6 +56,10 @@ See [the english unit tests](https://github.com/adamwdraper/Numeral-js/blob/mast
5156

5257
# Changelog
5358

59+
### 2.0.2
60+
61+
Bug fix: Updated module definitions
62+
5463
### 2.0.1
5564

5665
Bug fix: Fixed regression for webpack/browserify/rollup

Diff for: bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "numeral",
33
"repo": "adamwdraper/Numeral-js",
4-
"version": "2.0.1",
4+
"version": "2.0.2",
55
"description": "Format and manipulate numbers.",
66
"keywords": [
77
"numeral",

Diff for: component.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "numeral",
33
"repo": "adamwdraper/Numeral-js",
4-
"version": "2.0.1",
4+
"version": "2.0.2",
55
"description": "Format and manipulate numbers.",
66
"keywords": [
77
"numeral",

0 commit comments

Comments
 (0)