Skip to content

Commit

Permalink
chore(release): 2.0.0 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Jul 10, 2019
1 parent a781277 commit 16dbd11
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 63 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](http://semver.org).

## 2.0.0 - 2019-07-10

- refactor: using `async`/`await`

## 2.0.0-rc.3 - 2019-07-10

- fix: binaries
Expand Down
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,6 +1,6 @@
{
"name": "mozjpeg-binaries",
"version": "2.0.0-rc.3",
"version": "2.0.0",
"description": "Wrapper for mozjpeg binaries (cjpeg, djpeg, jpegtran, rdjpgcom, tjbench and wrjpgcom).",
"repository": {
"type": "git",
Expand Down
118 changes: 57 additions & 61 deletions src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const binBuild = require("bin-build");
const { default: PQueue } = require("p-queue");
const binWrappers = require("./bin-wrappers");

const buildCommands = () => {
const buildCommands = async () => {
const cpus = (os.cpus() || { length: 1 }).length;

let cfgExtras = "";
Expand All @@ -26,7 +26,7 @@ const buildCommands = () => {
`--prefix="${compilationDest}" --bindir="${compilationDest}" --libdir="${compilationDest}"`
].join(" ");

return binBuild.url(
await binBuild.url(
"https://github.com/mozilla/mozjpeg/archive/v3.3.1.tar.gz",
["autoreconf -fiv", cfg, `make -j${cpus}`, `make install -j${cpus}`]
);
Expand All @@ -37,76 +37,72 @@ const queue = new PQueue({ concurrency: 1 });
Object.keys(binWrappers).forEach(program => {
const binWrapper = binWrappers[program];

queue.add(() =>
Promise.resolve()
.then(() => {
if (process.env.COMPILATION_REQUIRED) {
throw new Error("Compilation required");
}
queue.add(async () => {
try {
if (process.env.COMPILATION_REQUIRED) {
throw new Error("Compilation required");
}

// eslint-disable-next-line promise/no-return-wrap
return Promise.resolve();
})
// Workaround https://github.com/kevva/bin-wrapper/issues/67
// Need use bin.run(['--version']) after resolve
.then(() => binWrapper.findExisting())
await binWrapper.findExisting();

// eslint-disable-next-line no-sync
.then(() => fs.chmodSync(binWrapper.path(), "755"))
.then(() => {
const commandWihtoutCheck = [
"rdjpgcom",
"tjbench",
"wrjpgcom"
].includes(program);
const checkCommand = commandWihtoutCheck ? ["-help"] : ["-version"];

return binWrapper
.runCheck(checkCommand)
.then(binCheck => {
console.log(`${program} pre-build test passed successfully`); // eslint-disable-line no-console

return binCheck;
})
.catch(error => {
const { message } = error;

if (commandWihtoutCheck && /usage/i.test(message)) {
console.log(`${program} pre-build test passed successfully`); // eslint-disable-line no-console

return;
}

throw error;
});
})
.catch(error => {
queue.pause();

if (!process.env.COMPILATION_REQUIRED) {
console.log(error.message); // eslint-disable-line no-console
console.log("pre-build test failed"); // eslint-disable-line no-console
fs.chmodSync(binWrapper.path(), "755");

const commandWihtoutCheck = ["rdjpgcom", "tjbench", "wrjpgcom"].includes(
program
);
const checkCommand = commandWihtoutCheck ? ["-help"] : ["-version"];

try {
await binWrapper.runCheck(checkCommand);
} catch (error) {
const { message } = error;

if (commandWihtoutCheck && /usage/i.test(message)) {
console.log(`${program} pre-build test passed successfully`); // eslint-disable-line no-console

return binWrapper;
}

console.log("compiling from source"); // eslint-disable-line no-console
throw error;
}

buildCommands()
.then(result => {
console.log("mozjpeg binaries built successfully"); // eslint-disable-line no-console
console.log(`${program} pre-build test passed successfully`); // eslint-disable-line no-console

return result;
})
.catch(buildError => {
console.log(buildError.stack); // eslint-disable-line no-console
return binWrapper;
} catch (error) {
queue.pause();

const exitCode =
typeof buildError.code === "number" ? buildError.code : 1;
if (!process.env.COMPILATION_REQUIRED) {
console.log(error.message); // eslint-disable-line no-console
console.log("pre-build test failed"); // eslint-disable-line no-console
}

process.exit(exitCode);
});
console.log("compiling from source"); // eslint-disable-line no-console

queue.clear();
})
);
// eslint-disable-next-line init-declarations
let result;

try {
result = await buildCommands();
} catch (buildError) {
console.log(buildError.stack); // eslint-disable-line no-console

const exitCode =
typeof buildError.code === "number" ? buildError.code : 1;

process.exit(exitCode);
}

console.log("mozjpeg binaries built successfully"); // eslint-disable-line no-console

queue.clear();

return result;
}
});
});

queue.start();

0 comments on commit 16dbd11

Please sign in to comment.