Skip to content

Commit

Permalink
Update dependencies and more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
as-com committed Apr 3, 2018
1 parent ed93c48 commit ddb7cfc
Show file tree
Hide file tree
Showing 5 changed files with 350 additions and 75 deletions.
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
"version": "3.3.1-beta.1",
"description": "Implementation of MozJPEG in pure JavaScript, using Emscripten",
"main": "dist/mozjpeg.js",
"jsnext:main": "dist/mozjpeg.es2015.js",
"jsnext:main": "dist/mozjpeg.es6.js",
"module": "dist/mozjpeg.es6.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup -c rollup.config.js",
"uglify": "uglifyjs dist/mozjpeg.js -o dist/mozjpeg.min.js -m -c"
"build": "npm run build:cjpeg && npm run build:rollup && npm run build:uglify",
"build:cjpeg": "./build-js.sh",
"build:rollup": "rollup -c rollup.config.js",
"build:uglify": "uglifyjs dist/mozjpeg.js -o dist/mozjpeg.min.js -m -c"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -35,8 +38,8 @@
"dist"
],
"devDependencies": {
"rollup": "^0.32.0",
"rollup-plugin-commonjs": "^3.0.0",
"rollup": "^0.57.1",
"rollup-plugin-commonjs": "^9.1.0",
"uglify-js": "^3.3.18"
}
}
2 changes: 1 addition & 1 deletion post.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
try {
file = FS.readFile("/output.jpg");
} catch (e) {
return new Error("No output: " + stderr);
throw new Error("No output: " + stderr);
}

FS.unlink("/output.jpg");
Expand Down
20 changes: 12 additions & 8 deletions pre.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
module.exports = function(file, options) {
// file: Typed array containing file in PPM, PGM, BMP, or Targa format.
// options: hash containing options to pass to cjpeg
// options: hash containing options to pass to cjpeg or an array of arguments
// returns: object, data = typed array with file output, stderr = command output

var stdout = "";
var stderr = "";

var args = ["-outfile", "/output.jpg"];

for (var key in options) {
if (!options.hasOwnProperty(key)) continue;
if (Array.isArray(options)) {
args = args.concat(options);
} else {
for (var key in options) {
if (!options.hasOwnProperty(key)) continue;

if (options[key]) {
args.push("-" + key);
if (typeof options[key] !== "boolean") {
// option has a value
args.push(String(options[key]));
if (options[key]) {
args.push("-" + key);
if (typeof options[key] !== "boolean") {
// option has a value
args.push(String(options[key]));
}
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import commonjs from 'rollup-plugin-commonjs';
import commonjs from "rollup-plugin-commonjs";

export default {
entry: 'index.js',
input: "index.js",
plugins: [commonjs()],
moduleName: "mozjpeg",
targets: [{
dest: 'dist/mozjpeg.js',
format: 'umd'
output: [{
file: "dist/mozjpeg.js",
format: "umd",
name: "mozjpeg"
}, {
dest: 'dist/mozjpeg.es6.js',
format: 'es'
file: "dist/mozjpeg.es6.js",
format: "es",
name: "mozjpeg"
}]
};
Loading

0 comments on commit ddb7cfc

Please sign in to comment.