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AA;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,6BAAa,CAAC,SAAS,CAAC,mCAAmC,CAAC,CAAA;YAC5D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,2BAA2B;IAC3B,4EAA4E;IAE5E;;OAEG;IACO,MAAM,CAAC,WAAW,CAAC,IAAY;QACrC,OAAO;;;eAGA,IAAI;;;CAGlB,CAAA;IACG,CAAC;CACJ;AArDD,0DAqDC","file":"SubscriberCreateCommand.js","sourcesContent":["import * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport path from \"path\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Generates a new subscriber.\n */\nexport class SubscriberCreateCommand implements yargs.CommandModule {\n command = \"subscriber:create \"\n describe = \"Generates a new subscriber.\"\n\n builder(args: yargs.Argv) {\n return args.positional(\"path\", {\n type: \"string\",\n describe: \"Path of the subscriber file\",\n demandOption: true,\n })\n }\n\n async handler(args: yargs.Arguments) {\n try {\n const fullPath = (args.path as string).startsWith(\"/\")\n ? (args.path as string)\n : path.resolve(process.cwd(), args.path as string)\n const filename = path.basename(fullPath)\n const fileContent = SubscriberCreateCommand.getTemplate(filename)\n const fileExists = await CommandUtils.fileExists(fullPath + \".ts\")\n if (fileExists) {\n throw `File ${chalk.blue(fullPath + \".ts\")} already exists`\n }\n await CommandUtils.createFile(fullPath + \".ts\", fileContent)\n console.log(\n chalk.green(\n `Subscriber ${chalk.blue(\n fullPath,\n )} has been created successfully.`,\n ),\n )\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during subscriber creation:\")\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets contents of the entity file.\n */\n protected static getTemplate(name: string): string {\n return `import { EventSubscriber, EntitySubscriberInterface } from \"typeorm\"\n\n@EventSubscriber()\nexport class ${name} implements EntitySubscriberInterface {\n\n}\n`\n }\n}\n"],"sourceRoot":".."}