UNPKG

@iobroker/create-adapter

Version:

Command line utility to create customized ioBroker adapters

25 lines 1.06 kB
"use strict"; const questions_1 = require("../../src/lib/core/questions"); const createAdapter_1 = require("../../src/lib/createAdapter"); const templateFunction = answers => { if (answers.icon) { if (typeof answers.icon.data === "string") { // Try to decode Base64 const base64Match = answers.icon.data.match(/^data:image\/([^;]+);base64,(.+)$/); if (base64Match) { return Buffer.from(base64Match[2], "base64"); } throw new Error("The icon has an unsupported string encoding!"); } else { // Return the raw buffer return answers.icon.data; } } // Fall back to reading the default image return (0, createAdapter_1.readFileFromRootDir)("../../adapter-creator.png", __dirname, true); }; templateFunction.customPath = answers => `admin/${(0, questions_1.getIconName)(answers)}`; templateFunction.noReformat = true; // Don't format binary files module.exports = templateFunction; //# sourceMappingURL=icon.png.js.map