Skip to content

Commit

Permalink
Revert "Merge pull request #104 from avoidwork/modernize"
Browse files Browse the repository at this point in the history
This reverts commit 1263ce4, reversing
changes made to b326ec5.
  • Loading branch information
avoidwork committed Oct 31, 2019
1 parent 74d98cc commit 3909b04
Show file tree
Hide file tree
Showing 20 changed files with 3,949 additions and 4,897 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
node_modules
.idea
*.tgz
node_modules/*
.idea/*
14 changes: 14 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/node_modules/
/lib/filesize.min.js
/lib/filesize.min.js.map
/lib/filesize.es6.min.js
/lib/filesize.es6.min.js.map
/src/
/test/
.idea
.eslintrc
.gitignore
.travis.yml
bower.json
composer.json
Gruntfile.js
101 changes: 101 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
"use strict";

var fs = require("fs"),
path = require("path");

module.exports = function (grunt) {
grunt.initConfig({
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"
},
dist: {
src: [
"<banner>",
"src/intro.js",
"src/filesize.js",
"src/outro.js"
],
dest: "lib/filesize.es6.js"
}
},
"babel": {
options: {
sourceMap: false,
presets: ["babel-preset-env"]
},
dist: {
files: {
"lib/<%= pkg.name %>.js": "lib/<%= pkg.name %>.es6.js"
}
}
},
eslint: {
target: [
"Gruntfile.js",
"test/*.js",
"lib/<%= pkg.name %>.es6.js"
]
},
nodeunit: {
all: ["test/*.js"]
},
uglify: {
options: {
banner: "/*\n <%= grunt.template.today('yyyy') %> <%= pkg.author %>\n @version <%= pkg.version %>\n*/",
sourceMap: true,
sourceMapIncludeSources: true
},
target: {
files: {
"lib/filesize.min.js": ["lib/filesize.js"]
}
}
},
watch: {
js: {
files: "<%= concat.dist.src %>",
tasks: "build"
},
pkg: {
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-uglify");
grunt.loadNpmTasks("grunt-babel");
grunt.loadNpmTasks("grunt-eslint");
grunt.task.registerTask("babili", "Minifies ES2016+ code", function () {
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\";";

fs.writeFileSync(path.join(__dirname, "lib", "filesize.es6.min.js"), banner + minified.code + "\n//# sourceMappingURL=filesize.es6.min.js.map", "utf8");
grunt.log.ok("1 file created.");
fs.writeFileSync(path.join(__dirname, "lib", "filesize.es6.min.js.map"), JSON.stringify(minified.map), "utf8");
grunt.log.ok("1 sourcemap created.");
});

// aliases
grunt.registerTask("test", ["eslint", "nodeunit"]);
grunt.registerTask("build", ["concat", "babel"]);
grunt.registerTask("default", ["build", "test", "babili", "uglify"]);
};
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ const size = filesize.partial({standard: "iec"});
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) 2019 Jason Mulligan
Licensed under the BSD-3 license.
5 changes: 0 additions & 5 deletions filesize.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +0,0 @@
export function filesize(arg: any, descriptor: object): any;

export interface filesize {
partial: any;
}
137 changes: 0 additions & 137 deletions lib/filesize.cjs.js

This file was deleted.

Loading

0 comments on commit 3909b04

Please sign in to comment.