thedesk/app/node_modules/builder-util/out/log.js.map
2019-09-12 23:38:13 +09:00

2 lines
7.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{"version":3,"sources":["../src/log.ts"],"names":[],"mappings":";;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;;;AAGA,IAAI,OAAO,GAAuC,IAAlD;AAEO,MAAM,KAAK,GAAG,qBAAO,kBAAP,CAAd;;;AAMD,SAAU,UAAV,CAAqB,KAArB,EAA8D;AAClE,EAAA,OAAO,GAAG,KAAV;AACD;;AAIM,MAAM,OAAO,GAAG,CAAhB;;;AAED,MAAO,MAAP,CAAa;AACjB,EAAA,WAAA,CAA+B,MAA/B,EAAqD;AAAtB,SAAA,MAAA,GAAA,MAAA;;AAG/B,SAAA,kBAAA,GAAqE,EAAE,IAAI,EAA3E;AAFC;;AAID,EAAA,QAAQ,CAAC,IAAD,EAAa;AACnB,UAAM,GAAG,GAAG,OAAO,CAAC,GAAR,EAAZ;AACA,WAAO,IAAI,CAAC,UAAL,CAAgB,GAAhB,IAAuB,IAAI,CAAC,SAAL,CAAe,GAAG,CAAC,MAAJ,GAAa,CAA5B,CAAvB,GAAwD,IAA/D;AACD,GATgB,CAWjB;;;AACA,MAAI,cAAJ,GAAkB;AAChB,WAAO,KAAK,CAAC,OAAb;AACD;;AAED,EAAA,IAAI,CAAC,eAAD,EAA0C,OAA1C,EAA0D;AAC5D,SAAK,KAAL,CAAW,OAAX,EAAoB,eAApB,EAAqC,MAArC;AACD;;AAED,EAAA,KAAK,CAAC,eAAD,EAA0C,OAA1C,EAA0D;AAC7D,SAAK,KAAL,CAAW,OAAX,EAAoB,eAApB,EAAqC,OAArC;AACD;;AAED,EAAA,IAAI,CAAC,eAAD,EAA0C,OAA1C,EAA0D;AAC5D,SAAK,KAAL,CAAW,OAAX,EAAoB,eAApB,EAAqC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KAAK,CAAC,IAAD,CAAM,IAAI,UAAU,EAApC;;AACA,UAAI,EAAE,OAAF,KAAc,UAAU,CAAC,MAA7B,EAAqC;AACnC,YAAI,YAAY,IAAI,IAApB,EAA0B;AACxB,UAAA,IAAI,IAAI,GAAR;AACD,SAFD,MAGK;AACH,UAAA,IAAI,IAAI,OAAO,YAAf;AACD;AACF;AACF;;AACD,WAAO,IAAP;AACD;;AAED,EAAA,GAAG,CAAC,OAAD,EAAgB;AACjB,QAAI,OAAO,IAAI,IAAf,EAAqB;AACnB,WAAK,MAAL,CAAY,KAAZ,CAAkB,GAAG,OAAO,IAA5B;AACD,KAFD,MAGK;AACH,MAAA,OAAO,CAAC,OAAD,CAAP;AACD;AACF;;AAzGgB;;;AA4GnB,MAAM,cAAc,GAA+B;AACjD,EAAA,IAAI,EAAE,iBAAM,IADqC;AAEjD,EAAA,IAAI,EAAE,iBAAM,MAFqC;AAGjD,EAAA,KAAK,EAAE,iBAAM,GAHoC;AAIjD,EAAA,KAAK,EAAE,iBAAM;AAJoC,CAAnD;AAOO,MAAM,GAAG,GAAG,IAAI,MAAJ,CAAW,OAAO,CAAC,MAAnB,CAAZ,C","sourcesContent":["import chalk, { Chalk } from \"chalk\"\nimport _debug from \"debug\"\nimport WritableStream = NodeJS.WritableStream\n\nlet printer: ((message: string) => void) | null = null\n\nexport const debug = _debug(\"electron-builder\")\n\nexport interface Fields {\n [index: string]: any\n}\n\nexport function setPrinter(value: ((message: string) => void) | null) {\n printer = value\n}\n\nexport type LogLevel = \"info\" | \"warn\" | \"debug\" | \"notice\" | \"error\"\n\nexport const PADDING = 2\n\nexport class Logger {\n constructor(protected readonly stream: WritableStream) {\n }\n\n messageTransformer: ((message: string, level: LogLevel) => string) = it => it\n\n filePath(file: string) {\n const cwd = process.cwd()\n return file.startsWith(cwd) ? file.substring(cwd.length + 1) : file\n }\n\n // noinspection JSMethodCanBeStatic\n get isDebugEnabled() {\n return debug.enabled\n }\n\n info(messageOrFields: Fields | null | string, message?: string) {\n this.doLog(message, messageOrFields, \"info\")\n }\n\n error(messageOrFields: Fields | null | string, message?: string) {\n this.doLog(message, messageOrFields, \"error\")\n }\n\n warn(messageOrFields: Fields | null | string, message?: string): void {\n this.doLog(message, messageOrFields, \"warn\")\n }\n\n debug(fields: Fields | null, message: string) {\n if (debug.enabled) {\n this._doLog(message, fields, \"debug\")\n }\n }\n\n private doLog(message: string | undefined | Error, messageOrFields: Fields | null | string, level: LogLevel) {\n if (message === undefined) {\n this._doLog(messageOrFields as string, null, level)\n }\n else {\n this._doLog(message, messageOrFields as Fields | null, level)\n }\n }\n\n private _doLog(message: string | Error, fields: Fields | null, level: LogLevel) {\n // noinspection SuspiciousInstanceOfGuard\n if (message instanceof Error) {\n message = message.stack || message.toString()\n }\n else {\n message = message.toString()\n }\n\n const levelIndicator = level === \"error\" ? \"\" : \"•\"\n const color = LEVEL_TO_COLOR[level]\n this.stream.write(`${\" \".repeat(PADDING)}${color(levelIndicator)} `)\n this.stream.write(Logger.createMessage(this.messageTransformer(message, level), fields, level, color, PADDING + 2 /* level indicator and space */))\n this.stream.write(\"\\n\")\n }\n\n static createMessage(message: string, fields: Fields | null, level: LogLevel, color: (it: string) => string, messagePadding = 0): string {\n if (fields == null) {\n return message\n }\n\n const fieldPadding = \" \".repeat(Math.max(2, 16 - message.length))\n let text = (level === \"error\" ? color(message) : message) + fieldPadding\n const fieldNames = Object.keys(fields)\n let counter = 0\n for (const name of fieldNames) {\n let fieldValue = fields[name]\n let valuePadding: string | null = null\n if (fieldValue != null && typeof fieldValue === \"string\" && fieldValue.includes(\"\\n\")) {\n valuePadding = \" \".repeat(messagePadding + message.length + fieldPadding.length + 2)\n fieldValue = \"\\n\" + valuePadding + fieldValue.replace(/\\n/g, `\\n${valuePadding}`)\n }\n else if (Array.isArray(fieldValue)) {\n fieldValue = JSON.stringify(fieldValue)\n }\n else if (Array.isArray(fieldValue)) {\n fieldValue = JSON.stringify(fieldValue)\n }\n else if (typeof fieldValue === \"object\") {\n // fieldValue = safeStringifyJson(fieldValue)\n }\n\n text += `${color(name)}=${fieldValue}`\n if (++counter !== fieldNames.length) {\n if (valuePadding == null) {\n text += \" \"\n }\n else {\n text += \"\\n\" + valuePadding\n }\n }\n }\n return text\n }\n\n log(message: string): void {\n if (printer == null) {\n this.stream.write(`${message}\\n`)\n }\n else {\n printer(message)\n }\n }\n}\n\nconst LEVEL_TO_COLOR: { [index: string]: Chalk } = {\n info: chalk.blue,\n warn: chalk.yellow,\n error: chalk.red,\n debug: chalk.white,\n}\n\nexport const log = new Logger(process.stdout)"],"sourceRoot":""}