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O,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;yBACjD;wBAED,IAAI,eAAe,IAAI,gBAAgB,IAAI,eAAe,KAAK,gBAAgB,EAAE;4BAC7E,OAAO,CAAC,GAAG,CAAC,0FAA0F;gCAClG,mEAAmE,CAAC,CAAC;yBAC5E;;;;;KACJ;IAEgB,6BAAc,GAA/B,UAAgC,OAAe;QAC3C,OAAO,IAAI,OAAO,CAAS,UAAC,EAAE,EAAE,IAAI;YAChC,IAAI,CAAC,OAAO,EAAE,UAAC,KAAU,EAAE,MAAW,EAAE,MAAW;gBAC/C,IAAI,MAAM;oBAAE,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;gBAC9B,IAAI,MAAM;oBAAE,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;gBAC9B,IAAI,KAAK;oBAAE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC9B,EAAE,CAAC,EAAE,CAAC,CAAC;YACX,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAEL,qBAAC;AAAD,CA1CA,AA0CC,IAAA;AA1CY,wCAAc","file":"VersionCommand.js","sourcesContent":["import * as yargs from \"yargs\";\nconst exec = require(\"child_process\").exec;\n\n/**\n * Shows typeorm version.\n */\nexport class VersionCommand implements yargs.CommandModule {\n command = \"version\";\n describe = \"Prints TypeORM version this project uses.\";\n\n async handler() {\n\n const localNpmList = await VersionCommand.executeCommand(\"npm list --depth=0\");\n const localMatches = localNpmList.match(/ typeorm@(.*)\\n/);\n const localNpmVersion = (localMatches && localMatches[1] ? localMatches[1] : \"\").replace(/\"invalid\"/gi, \"\").trim();\n\n const globalNpmList = await VersionCommand.executeCommand(\"npm list -g --depth=0\");\n const globalMatches = globalNpmList.match(/ typeorm@(.*)\\n/);\n const globalNpmVersion = (globalMatches && globalMatches[1] ? globalMatches[1] : \"\").replace(/\"invalid\"/gi, \"\").trim();\n\n if (localNpmVersion) {\n console.log(\"Local installed version:\", localNpmVersion);\n } else {\n console.log(\"No local installed TypeORM was found.\");\n }\n if (globalNpmVersion) {\n console.log(\"Global installed TypeORM version:\", globalNpmVersion);\n } else {\n console.log(\"No global installed was found.\");\n }\n\n if (localNpmVersion && globalNpmVersion && localNpmVersion !== globalNpmVersion) {\n console.log(\"To avoid issues with CLI please make sure your global and local TypeORM versions match, \" +\n \"or you are using locally installed TypeORM instead of global one.\");\n }\n }\n\n protected static executeCommand(command: string) {\n return new Promise<string>((ok, fail) => {\n exec(command, (error: any, stdout: any, stderr: any) => {\n if (stdout) return ok(stdout);\n if (stderr) return ok(stderr);\n if (error) return fail(error);\n ok(\"\");\n });\n });\n }\n\n}\n"],"sourceRoot":".."}
|