Skip to content

Commit 3909b04

Browse files
committed
Revert "Merge pull request #104 from avoidwork/modernize"
This reverts commit 1263ce4, reversing changes made to b326ec5.
1 parent 74d98cc commit 3909b04

20 files changed

+3949
-4897
lines changed

.gitignore

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
node_modules
2-
.idea
3-
*.tgz
1+
node_modules/*
2+
.idea/*

.npmignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/node_modules/
2+
/lib/filesize.min.js
3+
/lib/filesize.min.js.map
4+
/lib/filesize.es6.min.js
5+
/lib/filesize.es6.min.js.map
6+
/src/
7+
/test/
8+
.idea
9+
.eslintrc
10+
.gitignore
11+
.travis.yml
12+
bower.json
13+
composer.json
14+
Gruntfile.js

Gruntfile.js

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
"use strict";
2+
3+
var fs = require("fs"),
4+
path = require("path");
5+
6+
module.exports = function (grunt) {
7+
grunt.initConfig({
8+
pkg: grunt.file.readJSON("package.json"),
9+
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"
18+
},
19+
dist: {
20+
src: [
21+
"<banner>",
22+
"src/intro.js",
23+
"src/filesize.js",
24+
"src/outro.js"
25+
],
26+
dest: "lib/filesize.es6.js"
27+
}
28+
},
29+
"babel": {
30+
options: {
31+
sourceMap: false,
32+
presets: ["babel-preset-env"]
33+
},
34+
dist: {
35+
files: {
36+
"lib/<%= pkg.name %>.js": "lib/<%= pkg.name %>.es6.js"
37+
}
38+
}
39+
},
40+
eslint: {
41+
target: [
42+
"Gruntfile.js",
43+
"test/*.js",
44+
"lib/<%= pkg.name %>.es6.js"
45+
]
46+
},
47+
nodeunit: {
48+
all: ["test/*.js"]
49+
},
50+
uglify: {
51+
options: {
52+
banner: "/*\n <%= grunt.template.today('yyyy') %> <%= pkg.author %>\n @version <%= pkg.version %>\n*/",
53+
sourceMap: true,
54+
sourceMapIncludeSources: true
55+
},
56+
target: {
57+
files: {
58+
"lib/filesize.min.js": ["lib/filesize.js"]
59+
}
60+
}
61+
},
62+
watch: {
63+
js: {
64+
files: "<%= concat.dist.src %>",
65+
tasks: "build"
66+
},
67+
pkg: {
68+
files: "package.json",
69+
tasks: "build"
70+
}
71+
}
72+
});
73+
74+
// tasks
75+
grunt.loadNpmTasks("grunt-contrib-concat");
76+
grunt.loadNpmTasks("grunt-contrib-nodeunit");
77+
grunt.loadNpmTasks("grunt-contrib-watch");
78+
grunt.loadNpmTasks("grunt-contrib-uglify");
79+
grunt.loadNpmTasks("grunt-babel");
80+
grunt.loadNpmTasks("grunt-eslint");
81+
grunt.task.registerTask("babili", "Minifies ES2016+ code", function () {
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+
}),
88+
pkg = require(path.join(__dirname, "package.json")),
89+
banner = "/*\n " + new Date().getFullYear() + " " + pkg.author + "\n @version " + pkg.version + "\n*/\n\"use strict\";";
90+
91+
fs.writeFileSync(path.join(__dirname, "lib", "filesize.es6.min.js"), banner + minified.code + "\n//# sourceMappingURL=filesize.es6.min.js.map", "utf8");
92+
grunt.log.ok("1 file created.");
93+
fs.writeFileSync(path.join(__dirname, "lib", "filesize.es6.min.js.map"), JSON.stringify(minified.map), "utf8");
94+
grunt.log.ok("1 sourcemap created.");
95+
});
96+
97+
// aliases
98+
grunt.registerTask("test", ["eslint", "nodeunit"]);
99+
grunt.registerTask("build", ["concat", "babel"]);
100+
grunt.registerTask("default", ["build", "test", "babili", "uglify"]);
101+
};

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ const size = filesize.partial({standard: "iec"});
8282
size(265318); // "259.1 KiB"
8383
```
8484

85+
## How can I load filesize.js?
86+
filesize.js supports AMD loaders (require.js, curl.js, etc.), node.js & npm (```npm install filesize```), or using a script tag.
87+
88+
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'))`.
89+
8590
## License
8691
Copyright (c) 2019 Jason Mulligan
8792
Licensed under the BSD-3 license.

filesize.d.ts

-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +0,0 @@
1-
export function filesize(arg: any, descriptor: object): any;
2-
3-
export interface filesize {
4-
partial: any;
5-
}

lib/filesize.cjs.js

-137
This file was deleted.

0 commit comments

Comments
 (0)