UNPKG

@nwrks/webp-converter

Version:

A small node.js library for converting any image to webp file format or converting webp image to any image file format.

33 lines (29 loc) 1.19 kB
const path = require("path"); const resolve = require("resolve/sync"); //get os type then return path of respective platform library const temp_files = function (extra_path) { const modulePath = resolve("@nwrks/webp-converter", { basedir: __dirname }); if (!modulePath) throw new Error("webp-converter not found"); if ( (process.platform === "darwin" || process.platform === "linux" || process.arch === "x64") && extra_path ) { return extra_path; } if (process.platform === "darwin") { return path.join(modulePath, "../../", "/temp/"); //return osx library path } else if (process.platform === "linux") { return path.join(modulePath, "../../", "/temp/"); //return linux library path } else if (process.platform === "win32") { if (process.arch === "x64") { return path.join(modulePath, "../../", "\\temp\\"); //return windows 64bit library path } else { console.log("Unsupported platform:", process.platform, process.arch); //show unsupported platform message } } else { console.log("Unsupported platform:", process.platform, process.arch); //show unsupported platform message } }; module.exports = temp_files;