Skip to content

Commit

Permalink
Including ES6 version with npm install, updating grunt build such t…
Browse files Browse the repository at this point in the history
…hat more files are linted
  • Loading branch information
avoidwork committed Mar 24, 2018
1 parent dc04050 commit fb9bd3e
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 159 deletions.
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/node_modules/
/lib/filesize.min.js
/lib/filesize.min.js.map
/lib/filesize.es6.js
/lib/filesize.es6.min.js
/lib/filesize.es6.min.js.map
/src/
Expand Down
58 changes: 33 additions & 25 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
var fs = require("fs"),
path = require("path");

module.exports = function(grunt) {
module.exports = function (grunt) {
grunt.initConfig({
pkg : grunt.file.readJSON("package.json"),
pkg: grunt.file.readJSON("package.json"),
concat: {
options : {
banner : "/**\n" +
" * <%= pkg.name %>\n" +
" *\n" +
" * @copyright <%= grunt.template.today('yyyy') %> <%= pkg.author %>\n" +
" * @license <%= pkg.license %>\n" +
" * @version <%= pkg.version %>\n" +
" */\n"
options: {
banner: "/**\n" +
" * <%= pkg.name %>\n" +
" *\n" +
" * @copyright <%= grunt.template.today('yyyy') %> <%= pkg.author %>\n" +
" * @license <%= pkg.license %>\n" +
" * @version <%= pkg.version %>\n" +
" */\n"
},
dist: {
src : [
src: [
"<banner>",
"src/intro.js",
"src/filesize.js",
"src/outro.js"
],
dest : "lib/filesize.es6.js"
dest: "lib/filesize.es6.js"
}
},
"babel": {
Expand All @@ -38,10 +38,14 @@ module.exports = function(grunt) {
}
},
eslint: {
target: ["lib/<%= pkg.name %>.es6.js"]
target: [
"Gruntfile.js",
"test/*.js",
"lib/<%= pkg.name %>.es6.js"
]
},
nodeunit : {
all : ["test/*.js"]
nodeunit: {
all: ["test/*.js"]
},
uglify: {
options: {
Expand All @@ -51,32 +55,36 @@ module.exports = function(grunt) {
},
target: {
files: {
"lib/filesize.min.js" : ["lib/filesize.js"]
"lib/filesize.min.js": ["lib/filesize.js"]
}
}
},
watch : {
js : {
files : "<%= concat.dist.src %>",
tasks : "build"
watch: {
js: {
files: "<%= concat.dist.src %>",
tasks: "build"
},
pkg: {
files : "package.json",
tasks : "build"
files: "package.json",
tasks: "build"
}
}
});

// tasks
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-nodeunit");
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-babel");
grunt.loadNpmTasks("grunt-eslint");
grunt.task.registerTask("babili", "Minifies ES2016+ code", function () {
var data = fs.readFileSync(path.join(__dirname, "lib", "filesize.es6.js"), "utf8"),
minified = require("babel-core").transform(data, {sourceFileName: "filesize.es6.js", sourceMaps: true, presets: ["minify"]}),
const data = fs.readFileSync(path.join(__dirname, "lib", "filesize.es6.js"), "utf8"),
minified = require("babel-core").transform(data, {
sourceFileName: "filesize.es6.js",
sourceMaps: true,
presets: ["minify"]
}),
pkg = require(path.join(__dirname, "package.json")),
banner = "/*\n " + new Date().getFullYear() + " " + pkg.author + "\n @version " + pkg.version + "\n*/\n\"use strict\";";

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ size(265318); // "259.1 KiB"
## How can I load filesize.js?
filesize.js supports AMD loaders (require.js, curl.js, etc.), node.js & npm (```npm install filesize```), or using a script tag.

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'))`.

## License
Copyright (c) 2018 Jason Mulligan
Licensed under the BSD-3 license.
2 changes: 1 addition & 1 deletion lib/filesize.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @copyright 2018 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 3.6.0
* @version 3.6.1
*/
(function (global) {
const b = /^(b|B)$/,
Expand Down
2 changes: 1 addition & 1 deletion lib/filesize.es6.min.js

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

2 changes: 1 addition & 1 deletion lib/filesize.es6.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/filesize.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @copyright 2018 Jason Mulligan <jason.mulligan@avoidwork.com>
* @license BSD-3-Clause
* @version 3.6.0
* @version 3.6.1
*/
(function (global) {
var b = /^(b|B)$/,
Expand Down
2 changes: 1 addition & 1 deletion lib/filesize.min.js

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

2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "filesize",
"description": "JavaScript library to generate a human readable String describing the file size",
"version": "3.6.0",
"version": "3.6.1",
"homepage": "https://filesizejs.com",
"author": "Jason Mulligan <jason.mulligan@avoidwork.com>",
"repository": {
Expand Down
Loading

0 comments on commit fb9bd3e

Please sign in to comment.