typeorm 0.3.21-dev.981cf82 → 0.3.21-dev.988673c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/platform/BrowserPlatformTools.d.ts +1 -1
- package/browser/platform/BrowserPlatformTools.js +1 -1
- package/browser/platform/BrowserPlatformTools.js.map +1 -1
- package/browser/platform/PlatformTools.d.ts +1 -1
- package/browser/platform/PlatformTools.js +25 -13
- package/browser/platform/PlatformTools.js.map +1 -1
- package/commands/CacheClearCommand.d.ts +1 -1
- package/commands/CacheClearCommand.js +3 -3
- package/commands/CacheClearCommand.js.map +1 -1
- package/commands/EntityCreateCommand.d.ts +1 -1
- package/commands/EntityCreateCommand.js +7 -7
- package/commands/EntityCreateCommand.js.map +1 -1
- package/commands/InitCommand.d.ts +1 -1
- package/commands/InitCommand.js +8 -8
- package/commands/InitCommand.js.map +1 -1
- package/commands/MigrationCreateCommand.d.ts +1 -1
- package/commands/MigrationCreateCommand.js +5 -5
- package/commands/MigrationCreateCommand.js.map +1 -1
- package/commands/MigrationGenerateCommand.d.ts +1 -1
- package/commands/MigrationGenerateCommand.js +17 -17
- package/commands/MigrationGenerateCommand.js.map +1 -1
- package/commands/QueryCommand.d.ts +1 -1
- package/commands/QueryCommand.js +5 -6
- package/commands/QueryCommand.js.map +1 -1
- package/commands/SchemaDropCommand.d.ts +1 -1
- package/commands/SchemaDropCommand.js +3 -3
- package/commands/SchemaDropCommand.js.map +1 -1
- package/commands/SchemaLogCommand.d.ts +1 -1
- package/commands/SchemaLogCommand.js +11 -16
- package/commands/SchemaLogCommand.js.map +1 -1
- package/commands/SchemaSyncCommand.d.ts +1 -1
- package/commands/SchemaSyncCommand.js +3 -3
- package/commands/SchemaSyncCommand.js.map +1 -1
- package/commands/SubscriberCreateCommand.d.ts +1 -1
- package/commands/SubscriberCreateCommand.js +5 -5
- package/commands/SubscriberCreateCommand.js.map +1 -1
- package/package.json +1 -1
- package/platform/PlatformTools.d.ts +1 -1
- package/platform/PlatformTools.js +27 -15
- package/platform/PlatformTools.js.map +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatformTools = exports.Writable = exports.Readable = exports.
|
|
3
|
+
exports.PlatformTools = exports.Writable = exports.Readable = exports.ReadStream = exports.EventEmitter = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
6
|
-
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
5
|
+
const ansis_1 = tslib_1.__importDefault(require("ansis"));
|
|
7
6
|
const dotenv_1 = tslib_1.__importDefault(require("dotenv"));
|
|
8
|
-
const
|
|
7
|
+
const fs_1 = tslib_1.__importDefault(require("fs"));
|
|
8
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
9
9
|
const sql_highlight_1 = require("sql-highlight");
|
|
10
|
-
var fs_2 = require("fs");
|
|
11
|
-
Object.defineProperty(exports, "ReadStream", { enumerable: true, get: function () { return fs_2.ReadStream; } });
|
|
12
10
|
var events_1 = require("events");
|
|
13
11
|
Object.defineProperty(exports, "EventEmitter", { enumerable: true, get: function () { return events_1.EventEmitter; } });
|
|
12
|
+
var fs_2 = require("fs");
|
|
13
|
+
Object.defineProperty(exports, "ReadStream", { enumerable: true, get: function () { return fs_2.ReadStream; } });
|
|
14
14
|
var stream_1 = require("stream");
|
|
15
15
|
Object.defineProperty(exports, "Readable", { enumerable: true, get: function () { return stream_1.Readable; } });
|
|
16
16
|
Object.defineProperty(exports, "Writable", { enumerable: true, get: function () { return stream_1.Writable; } });
|
|
@@ -174,34 +174,46 @@ class PlatformTools {
|
|
|
174
174
|
* Highlights sql string to be printed in the console.
|
|
175
175
|
*/
|
|
176
176
|
static highlightSql(sql) {
|
|
177
|
-
return (0, sql_highlight_1.highlight)(sql
|
|
177
|
+
return (0, sql_highlight_1.highlight)(sql, {
|
|
178
|
+
colors: {
|
|
179
|
+
keyword: ansis_1.default.blueBright.open,
|
|
180
|
+
function: ansis_1.default.magentaBright.open,
|
|
181
|
+
number: ansis_1.default.green.open,
|
|
182
|
+
string: ansis_1.default.white.open,
|
|
183
|
+
identifier: ansis_1.default.white.open,
|
|
184
|
+
special: ansis_1.default.white.open,
|
|
185
|
+
bracket: ansis_1.default.white.open,
|
|
186
|
+
comment: ansis_1.default.gray.open,
|
|
187
|
+
clear: ansis_1.default.reset.open,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
178
190
|
}
|
|
179
191
|
/**
|
|
180
192
|
* Logging functions needed by AdvancedConsoleLogger
|
|
181
193
|
*/
|
|
182
194
|
static logInfo(prefix, info) {
|
|
183
|
-
console.log(
|
|
195
|
+
console.log(ansis_1.default.gray.underline(prefix), info);
|
|
184
196
|
}
|
|
185
197
|
static logError(prefix, error) {
|
|
186
|
-
console.log(
|
|
198
|
+
console.log(ansis_1.default.underline.red(prefix), error);
|
|
187
199
|
}
|
|
188
200
|
static logWarn(prefix, warning) {
|
|
189
|
-
console.log(
|
|
201
|
+
console.log(ansis_1.default.underline.yellow(prefix), warning);
|
|
190
202
|
}
|
|
191
203
|
static log(message) {
|
|
192
|
-
console.log(
|
|
204
|
+
console.log(ansis_1.default.underline(message));
|
|
193
205
|
}
|
|
194
206
|
static info(info) {
|
|
195
|
-
return
|
|
207
|
+
return ansis_1.default.gray(info);
|
|
196
208
|
}
|
|
197
209
|
static error(error) {
|
|
198
|
-
return
|
|
210
|
+
return ansis_1.default.red(error);
|
|
199
211
|
}
|
|
200
212
|
static warn(message) {
|
|
201
|
-
return
|
|
213
|
+
return ansis_1.default.yellow(message);
|
|
202
214
|
}
|
|
203
215
|
static logCmdErr(prefix, err) {
|
|
204
|
-
console.log(
|
|
216
|
+
console.log(ansis_1.default.black.bgRed(prefix));
|
|
205
217
|
if (err)
|
|
206
218
|
console.error(err);
|
|
207
219
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plat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AC,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAA;IACnD,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,MAAc,EAAE,KAAU;QACtC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,CAAA;IACnD,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,MAAc,EAAE,OAAY;QACvC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAA;IACxD,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,OAAe;QACtB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IACzC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,IAAS;QACjB,OAAO,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAU;QACnB,OAAO,eAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAe;QACvB,OAAO,eAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAChC,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAAc,EAAE,GAAS;QACtC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;QACtC,IAAI,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;;AAvOL,sCAwOC;AAvOG;;GAEG;AACI,kBAAI,GAAuB,MAAM,CAAA","file":"PlatformTools.js","sourcesContent":["import path from \"path\"\nimport fs from \"fs\"\nimport dotenv from \"dotenv\"\nimport chalk from \"chalk\"\nimport { highlight } from \"sql-highlight\"\n\nexport { ReadStream } from \"fs\"\nexport { EventEmitter } from \"events\"\nexport { Readable, Writable } from \"stream\"\n\n/**\n * Platform-specific tools.\n */\nexport class PlatformTools {\n /**\n * Type of the currently running platform.\n */\n static type: \"browser\" | \"node\" = \"node\"\n\n /**\n * Gets global variable where global stuff can be stored.\n */\n static getGlobalVariable(): any {\n return global\n }\n\n /**\n * Loads (\"require\"-s) given file or package.\n * This operation only supports on node platform\n */\n static load(name: string): any {\n // if name is not absolute or relative, then try to load package from the node_modules of the directory we are currently in\n // this is useful when we are using typeorm package globally installed and it accesses drivers\n // that are not installed globally\n\n try {\n // switch case to explicit require statements for webpack compatibility.\n switch (name) {\n /**\n * spanner\n */\n case \"spanner\":\n return require(\"@google-cloud/spanner\")\n\n /**\n * mongodb\n */\n case \"mongodb\":\n return require(\"mongodb\")\n\n /**\n * hana\n */\n case \"@sap/hana-client\":\n return require(\"@sap/hana-client\")\n\n case \"@sap/hana-client/extension/Stream\":\n return require(\"@sap/hana-client/extension/Stream\")\n\n case \"hdb-pool\":\n return require(\"hdb-pool\")\n\n /**\n * mysql\n */\n case \"mysql\":\n return require(\"mysql\")\n\n case \"mysql2\":\n return require(\"mysql2\")\n\n /**\n * oracle\n */\n case \"oracledb\":\n return require(\"oracledb\")\n\n /**\n * postgres\n */\n case \"pg\":\n return require(\"pg\")\n\n case \"pg-native\":\n return require(\"pg-native\")\n\n case \"pg-query-stream\":\n return require(\"pg-query-stream\")\n\n case \"typeorm-aurora-data-api-driver\":\n return require(\"typeorm-aurora-data-api-driver\")\n\n /**\n * redis\n */\n case \"redis\":\n return require(\"redis\")\n\n case \"ioredis\":\n return require(\"ioredis\")\n\n /**\n * better-sqlite3\n */\n case \"better-sqlite3\":\n return require(\"better-sqlite3\")\n\n /**\n * sqlite\n */\n case \"sqlite3\":\n return require(\"sqlite3\")\n\n /**\n * sql.js\n */\n case \"sql.js\":\n return require(\"sql.js\")\n\n /**\n * sqlserver\n */\n case \"mssql\":\n return require(\"mssql\")\n\n /**\n * react-native-sqlite\n */\n case \"react-native-sqlite-storage\":\n return require(\"react-native-sqlite-storage\")\n }\n } catch (err) {\n return require(path.resolve(\n process.cwd() + \"/node_modules/\" + name,\n ))\n }\n\n // If nothing above matched and we get here, the package was not listed within PlatformTools\n // and is an Invalid Package. To make it explicit that this is NOT the intended use case for\n // PlatformTools.load - it's not just a way to replace `require` all willy-nilly - let's throw\n // an error.\n throw new TypeError(`Invalid Package for PlatformTools.load: ${name}`)\n }\n\n /**\n * Normalizes given path. Does \"path.normalize\" and replaces backslashes with forward slashes on Windows.\n */\n static pathNormalize(pathStr: string): string {\n let normalizedPath = path.normalize(pathStr)\n if (process.platform === \"win32\")\n normalizedPath = normalizedPath.replace(/\\\\/g, \"/\")\n return normalizedPath\n }\n\n /**\n * Gets file extension. Does \"path.extname\".\n */\n static pathExtname(pathStr: string): string {\n return path.extname(pathStr)\n }\n\n /**\n * Resolved given path. Does \"path.resolve\".\n */\n static pathResolve(pathStr: string): string {\n return path.resolve(pathStr)\n }\n\n /**\n * Synchronously checks if file exist. Does \"fs.existsSync\".\n */\n static fileExist(pathStr: string): boolean {\n return fs.existsSync(pathStr)\n }\n\n static readFileSync(filename: string): Buffer {\n return fs.readFileSync(filename)\n }\n\n static appendFileSync(filename: string, data: any): void {\n fs.appendFileSync(filename, data)\n }\n\n static async writeFile(path: string, data: any): Promise<void> {\n return fs.promises.writeFile(path, data)\n }\n\n /**\n * Loads a dotenv file into the environment variables.\n *\n * @param path The file to load as a dotenv configuration\n */\n static dotenv(pathStr: string): void {\n dotenv.config({ path: pathStr })\n }\n\n /**\n * Gets environment variable.\n */\n static getEnvVariable(name: string): any {\n return process.env[name]\n }\n\n /**\n * Highlights sql string to be printed in the console.\n */\n static highlightSql(sql: string) {\n return highlight(sql)\n }\n\n /**\n * Logging functions needed by AdvancedConsoleLogger\n */\n static logInfo(prefix: string, info: any) {\n console.log(chalk.gray.underline(prefix), info)\n }\n\n static logError(prefix: string, error: any) {\n console.log(chalk.underline.red(prefix), error)\n }\n\n static logWarn(prefix: string, warning: any) {\n console.log(chalk.underline.yellow(prefix), warning)\n }\n\n static log(message: string) {\n console.log(chalk.underline(message))\n }\n\n static info(info: any) {\n return chalk.gray(info)\n }\n\n static error(error: any) {\n return chalk.red(error)\n }\n\n static warn(message: string) {\n return chalk.yellow(message)\n }\n\n static logCmdErr(prefix: string, err?: any) {\n console.log(chalk.black.bgRed(prefix))\n if (err) console.error(err)\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/platform/PlatformTools.ts"],"names":[],"mappings":";;;;AAAA,0DAAwB;AACxB,4DAA2B;AAC3B,oDAAmB;AACnB,wDAAuB;AACvB,iDAAyC;AAEzC,iCAAqC;AAA5B,sGAAA,YAAY,OAAA;AACrB,yBAA+B;AAAtB,gGAAA,UAAU,OAAA;AACnB,iCAA2C;AAAlC,kGAAA,QAAQ,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAE3B;;GAEG;AACH,MAAa,aAAa;IAMtB;;OAEG;IACH,MAAM,CAAC,iBAAiB;QACpB,OAAO,MAAM,CAAA;IACjB,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,IAAY;QACpB,2HAA2H;QAC3H,8FAA8F;QAC9F,kCAAkC;QAElC,IAAI,CAAC;YACD,wEAAwE;YACxE,QAAQ,IAAI,EAAE,CAAC;gBACX;;mBAEG;gBACH,KAAK,SAAS;oBACV,OAAO,OAAO,CAAC,uBAAuB,CAAC,CAAA;gBAE3C;;mBAEG;gBACH,KAAK,SAAS;oBACV,OAAO,OAAO,CAAC,SAAS,CAAC,CAAA;gBAE7B;;mBAEG;gBACH,KAAK,kBAAkB;oBACnB,OAAO,OAAO,CAAC,kBAAkB,CAAC,CAAA;gBAEtC,KAAK,mCAAmC;oBACpC,OAAO,OAAO,CAAC,mCAAmC,CAAC,CAAA;gBAEvD,KAAK,UAAU;oBACX,OAAO,OAAO,CAAC,UAAU,CAAC,CAAA;gBAE9B;;mBAEG;gBACH,KAA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,CAAC,GAAG,CAAC,eAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IACxC,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,IAAS;QACjB,OAAO,eAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,KAAU;QACnB,OAAO,eAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAe;QACvB,OAAO,eAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC/B,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,MAAc,EAAE,GAAS;QACtC,OAAO,CAAC,GAAG,CAAC,eAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;QACrC,IAAI,GAAG;YAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;;AAnPL,sCAoPC;AAnPG;;GAEG;AACI,kBAAI,GAAuB,MAAM,CAAA","file":"PlatformTools.js","sourcesContent":["import ansi from \"ansis\"\nimport dotenv from \"dotenv\"\nimport fs from \"fs\"\nimport path from \"path\"\nimport { highlight } from \"sql-highlight\"\n\nexport { EventEmitter } from \"events\"\nexport { ReadStream } from \"fs\"\nexport { Readable, Writable } from \"stream\"\n\n/**\n * Platform-specific tools.\n */\nexport class PlatformTools {\n /**\n * Type of the currently running platform.\n */\n static type: \"browser\" | \"node\" = \"node\"\n\n /**\n * Gets global variable where global stuff can be stored.\n */\n static getGlobalVariable(): any {\n return global\n }\n\n /**\n * Loads (\"require\"-s) given file or package.\n * This operation only supports on node platform\n */\n static load(name: string): any {\n // if name is not absolute or relative, then try to load package from the node_modules of the directory we are currently in\n // this is useful when we are using typeorm package globally installed and it accesses drivers\n // that are not installed globally\n\n try {\n // switch case to explicit require statements for webpack compatibility.\n switch (name) {\n /**\n * spanner\n */\n case \"spanner\":\n return require(\"@google-cloud/spanner\")\n\n /**\n * mongodb\n */\n case \"mongodb\":\n return require(\"mongodb\")\n\n /**\n * hana\n */\n case \"@sap/hana-client\":\n return require(\"@sap/hana-client\")\n\n case \"@sap/hana-client/extension/Stream\":\n return require(\"@sap/hana-client/extension/Stream\")\n\n case \"hdb-pool\":\n return require(\"hdb-pool\")\n\n /**\n * mysql\n */\n case \"mysql\":\n return require(\"mysql\")\n\n case \"mysql2\":\n return require(\"mysql2\")\n\n /**\n * oracle\n */\n case \"oracledb\":\n return require(\"oracledb\")\n\n /**\n * postgres\n */\n case \"pg\":\n return require(\"pg\")\n\n case \"pg-native\":\n return require(\"pg-native\")\n\n case \"pg-query-stream\":\n return require(\"pg-query-stream\")\n\n case \"typeorm-aurora-data-api-driver\":\n return require(\"typeorm-aurora-data-api-driver\")\n\n /**\n * redis\n */\n case \"redis\":\n return require(\"redis\")\n\n case \"ioredis\":\n return require(\"ioredis\")\n\n /**\n * better-sqlite3\n */\n case \"better-sqlite3\":\n return require(\"better-sqlite3\")\n\n /**\n * sqlite\n */\n case \"sqlite3\":\n return require(\"sqlite3\")\n\n /**\n * sql.js\n */\n case \"sql.js\":\n return require(\"sql.js\")\n\n /**\n * sqlserver\n */\n case \"mssql\":\n return require(\"mssql\")\n\n /**\n * react-native-sqlite\n */\n case \"react-native-sqlite-storage\":\n return require(\"react-native-sqlite-storage\")\n }\n } catch (err) {\n return require(path.resolve(\n process.cwd() + \"/node_modules/\" + name,\n ))\n }\n\n // If nothing above matched and we get here, the package was not listed within PlatformTools\n // and is an Invalid Package. To make it explicit that this is NOT the intended use case for\n // PlatformTools.load - it's not just a way to replace `require` all willy-nilly - let's throw\n // an error.\n throw new TypeError(`Invalid Package for PlatformTools.load: ${name}`)\n }\n\n /**\n * Normalizes given path. Does \"path.normalize\" and replaces backslashes with forward slashes on Windows.\n */\n static pathNormalize(pathStr: string): string {\n let normalizedPath = path.normalize(pathStr)\n if (process.platform === \"win32\")\n normalizedPath = normalizedPath.replace(/\\\\/g, \"/\")\n return normalizedPath\n }\n\n /**\n * Gets file extension. Does \"path.extname\".\n */\n static pathExtname(pathStr: string): string {\n return path.extname(pathStr)\n }\n\n /**\n * Resolved given path. Does \"path.resolve\".\n */\n static pathResolve(pathStr: string): string {\n return path.resolve(pathStr)\n }\n\n /**\n * Synchronously checks if file exist. Does \"fs.existsSync\".\n */\n static fileExist(pathStr: string): boolean {\n return fs.existsSync(pathStr)\n }\n\n static readFileSync(filename: string): Buffer {\n return fs.readFileSync(filename)\n }\n\n static appendFileSync(filename: string, data: any): void {\n fs.appendFileSync(filename, data)\n }\n\n static async writeFile(path: string, data: any): Promise<void> {\n return fs.promises.writeFile(path, data)\n }\n\n /**\n * Loads a dotenv file into the environment variables.\n *\n * @param path The file to load as a dotenv configuration\n */\n static dotenv(pathStr: string): void {\n dotenv.config({ path: pathStr })\n }\n\n /**\n * Gets environment variable.\n */\n static getEnvVariable(name: string): any {\n return process.env[name]\n }\n\n /**\n * Highlights sql string to be printed in the console.\n */\n static highlightSql(sql: string) {\n return highlight(sql, {\n colors: {\n keyword: ansi.blueBright.open,\n function: ansi.magentaBright.open,\n number: ansi.green.open,\n string: ansi.white.open,\n identifier: ansi.white.open,\n special: ansi.white.open,\n bracket: ansi.white.open,\n comment: ansi.gray.open,\n clear: ansi.reset.open,\n },\n })\n }\n\n /**\n * Logging functions needed by AdvancedConsoleLogger\n */\n static logInfo(prefix: string, info: any) {\n console.log(ansi.gray.underline(prefix), info)\n }\n\n static logError(prefix: string, error: any) {\n console.log(ansi.underline.red(prefix), error)\n }\n\n static logWarn(prefix: string, warning: any) {\n console.log(ansi.underline.yellow(prefix), warning)\n }\n\n static log(message: string) {\n console.log(ansi.underline(message))\n }\n\n static info(info: any) {\n return ansi.gray(info)\n }\n\n static error(error: any) {\n return ansi.red(error)\n }\n\n static warn(message: string) {\n return ansi.yellow(message)\n }\n\n static logCmdErr(prefix: string, err?: any) {\n console.log(ansi.black.bgRed(prefix))\n if (err) console.error(err)\n }\n}\n"],"sourceRoot":".."}
|