Skip to content

Commit fb9bd3e

Browse files
committed
Including ES6 version with npm install, updating grunt build such that more files are linted
1 parent dc04050 commit fb9bd3e

11 files changed

+147
-159
lines changed

.npmignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/node_modules/
22
/lib/filesize.min.js
33
/lib/filesize.min.js.map
4-
/lib/filesize.es6.js
54
/lib/filesize.es6.min.js
65
/lib/filesize.es6.min.js.map
76
/src/

Gruntfile.js

+33-25
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@
33
var fs = require("fs"),
44
path = require("path");
55

6-
module.exports = function(grunt) {
6+
module.exports = function (grunt) {
77
grunt.initConfig({
8-
pkg : grunt.file.readJSON("package.json"),
8+
pkg: grunt.file.readJSON("package.json"),
99
concat: {
10-
options : {
11-
banner : "/**\n" +
12-
" * <%= pkg.name %>\n" +
13-
" *\n" +
14-
" * @copyright <%= grunt.template.today('yyyy') %> <%= pkg.author %>\n" +
15-
" * @license <%= pkg.license %>\n" +
16-
" * @version <%= pkg.version %>\n" +
17-
" */\n"
10+
options: {
11+
banner: "/**\n" +
12+
" * <%= pkg.name %>\n" +
13+
" *\n" +
14+
" * @copyright <%= grunt.template.today('yyyy') %> <%= pkg.author %>\n" +
15+
" * @license <%= pkg.license %>\n" +
16+
" * @version <%= pkg.version %>\n" +
17+
" */\n"
1818
},
1919
dist: {
20-
src : [
20+
src: [
2121
"<banner>",
2222
"src/intro.js",
2323
"src/filesize.js",
2424
"src/outro.js"
2525
],
26-
dest : "lib/filesize.es6.js"
26+
dest: "lib/filesize.es6.js"
2727
}
2828
},
2929
"babel": {
@@ -38,10 +38,14 @@ module.exports = function(grunt) {
3838
}
3939
},
4040
eslint: {
41-
target: ["lib/<%= pkg.name %>.es6.js"]
41+
target: [
42+
"Gruntfile.js",
43+
"test/*.js",
44+
"lib/<%= pkg.name %>.es6.js"
45+
]
4246
},
43-
nodeunit : {
44-
all : ["test/*.js"]
47+
nodeunit: {
48+
all: ["test/*.js"]
4549
},
4650
uglify: {
4751
options: {
@@ -51,32 +55,36 @@ module.exports = function(grunt) {
5155
},
5256
target: {
5357
files: {
54-
"lib/filesize.min.js" : ["lib/filesize.js"]
58+
"lib/filesize.min.js": ["lib/filesize.js"]
5559
}
5660
}
5761
},
58-
watch : {
59-
js : {
60-
files : "<%= concat.dist.src %>",
61-
tasks : "build"
62+
watch: {
63+
js: {
64+
files: "<%= concat.dist.src %>",
65+
tasks: "build"
6266
},
6367
pkg: {
64-
files : "package.json",
65-
tasks : "build"
68+
files: "package.json",
69+
tasks: "build"
6670
}
6771
}
6872
});
6973

7074
// tasks
7175
grunt.loadNpmTasks("grunt-contrib-concat");
7276
grunt.loadNpmTasks("grunt-contrib-nodeunit");
73-
grunt.loadNpmTasks('grunt-contrib-watch');
77+
grunt.loadNpmTasks("grunt-contrib-watch");
7478
grunt.loadNpmTasks("grunt-contrib-uglify");
7579
grunt.loadNpmTasks("grunt-babel");
7680
grunt.loadNpmTasks("grunt-eslint");
7781
grunt.task.registerTask("babili", "Minifies ES2016+ code", function () {
78-
var data = fs.readFileSync(path.join(__dirname, "lib", "filesize.es6.js"), "utf8"),
79-
minified = require("babel-core").transform(data, {sourceFileName: "filesize.es6.js", sourceMaps: true, presets: ["minify"]}),
82+
const data = fs.readFileSync(path.join(__dirname, "lib", "filesize.es6.js"), "utf8"),
83+
minified = require("babel-core").transform(data, {
84+
sourceFileName: "filesize.es6.js",
85+
sourceMaps: true,
86+
presets: ["minify"]
87+
}),
8088
pkg = require(path.join(__dirname, "package.json")),
8189
banner = "/*\n " + new Date().getFullYear() + " " + pkg.author + "\n @version " + pkg.version + "\n*/\n\"use strict\";";
8290

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ size(265318); // "259.1 KiB"
8181
## How can I load filesize.js?
8282
filesize.js supports AMD loaders (require.js, curl.js, etc.), node.js & npm (```npm install filesize```), or using a script tag.
8383

84+
An ES6 version is bundled with an npm install, but requires you load it with the full path, e.g. `require(path.join(__dirname, 'node_modules', 'filesize', 'lib', 'filesize.es6.js'))`.
85+
8486
## License
8587
Copyright (c) 2018 Jason Mulligan
8688
Licensed under the BSD-3 license.

lib/filesize.es6.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* @copyright 2018 Jason Mulligan <[email protected]>
55
* @license BSD-3-Clause
6-
* @version 3.6.0
6+
* @version 3.6.1
77
*/
88
(function (global) {
99
const b = /^(b|B)$/,

lib/filesize.es6.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/filesize.es6.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/filesize.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* @copyright 2018 Jason Mulligan <[email protected]>
77
* @license BSD-3-Clause
8-
* @version 3.6.0
8+
* @version 3.6.1
99
*/
1010
(function (global) {
1111
var b = /^(b|B)$/,

lib/filesize.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "filesize",
33
"description": "JavaScript library to generate a human readable String describing the file size",
4-
"version": "3.6.0",
4+
"version": "3.6.1",
55
"homepage": "https://filesizejs.com",
66
"author": "Jason Mulligan <[email protected]>",
77
"repository": {

0 commit comments

Comments
 (0)