node-webp
Version:
WebP support for Node.js
31 lines • 1.12 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOutputFilepath = exports.getCommand = exports.execute = void 0;
const child_process_1 = require("child_process");
const util_1 = require("util");
const path_1 = require("path");
exports.execute = (0, util_1.promisify)(child_process_1.execFile);
function getCommand(command) {
let platform;
switch (process.platform) {
case "win32":
platform = "windows-x64";
break;
case "linux":
platform = "linux-x86-64";
break;
case "darwin":
platform = "mac-x86-64";
break;
default:
throw new Error("Platform is not supported");
}
return (0, path_1.join)(__dirname, "../", "webp", platform, command);
}
exports.getCommand = getCommand;
function getOutputFilepath(imageFilepath) {
const imageExtension = (0, path_1.extname)(imageFilepath);
return imageFilepath.replace(imageExtension, ".webp");
}
exports.getOutputFilepath = getOutputFilepath;
//# sourceMappingURL=util.js.map
;