diff --git a/package-lock.json b/package-lock.json index d817d59..3b7fc5a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/artisan", - "version": "4.19.0", + "version": "4.19.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@athenna/artisan", - "version": "4.19.0", + "version": "4.19.1", "license": "MIT", "dependencies": { "chalk-rainbow": "^1.0.0", diff --git a/package.json b/package.json index 80aec07..34a6391 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/artisan", - "version": "4.19.0", + "version": "4.19.1", "description": "The Athenna CLI application. Built on top of commander and inspired in @adonisjs/ace.", "license": "MIT", "author": "João Lenon ", diff --git a/src/commands/TemplateCustomizeCommand.ts b/src/commands/TemplateCustomizeCommand.ts index ba1f942..68f4f69 100644 --- a/src/commands/TemplateCustomizeCommand.ts +++ b/src/commands/TemplateCustomizeCommand.ts @@ -9,7 +9,7 @@ import { BaseCommand } from '#src' import { Exec, File } from '@athenna/common' -import { resolve, isAbsolute } from 'node:path' +import { resolve, relative, isAbsolute } from 'node:path' export class TemplateCustomizeCommand extends BaseCommand { public static signature(): string { @@ -38,7 +38,7 @@ export class TemplateCustomizeCommand extends BaseCommand { await file.copy(copyPath) - templates[key] = copyPath.replace(Path.pwd(), '.') + templates[key] = `./${this.templatesPath()}/${file.base}` }) await this.rc.setTo('templates', templates).save() @@ -52,9 +52,11 @@ export class TemplateCustomizeCommand extends BaseCommand { ) this.logger.success( - `Template files successfully moved to ({yellow} ${Path.resources( - 'templates' - ).replace(Path.pwd(), '.')}) folder.` + `Template files successfully moved to ({yellow} ${this.templatesPath()}) folder` ) } + + private templatesPath() { + return relative(Path.pwd(), Path.resources('templates')).replace(/\\/g, '/') + } } diff --git a/tests/unit/commands/TemplateCustomizeCommandTest.ts b/tests/unit/commands/TemplateCustomizeCommandTest.ts index 4d86bec..48e165d 100644 --- a/tests/unit/commands/TemplateCustomizeCommandTest.ts +++ b/tests/unit/commands/TemplateCustomizeCommandTest.ts @@ -22,7 +22,7 @@ export default class TemplateCustomizeCommandTest extends BaseTest { output.assertLogged('[ MOVING TEMPLATES ]') output.assertLogged('Athenna RC updated:') output.assertLogged('"command": "./resources/templates/command.edge"') - output.assertLogged('[ success ] Template files successfully moved to ./resources/templates folder.') + output.assertLogged('[ success ] Template files successfully moved to resources/templates folder') assert.isTrue(await Folder.exists(Path.resources())) assert.isTrue(await File.exists(Path.resources('templates/command.edge'))) assert.equal(athenna.templates.command, './resources/templates/command.edge') @@ -44,7 +44,7 @@ export default class TemplateCustomizeCommandTest extends BaseTest { output.assertLogged('Athenna RC updated:') output.assertLogged('"command": "./resources/templates/command.edge"') output.assertLogged('"test": "./resources/templates/test.edge"') - output.assertLogged('[ success ] Template files successfully moved to ./resources/templates folder.') + output.assertLogged('[ success ] Template files successfully moved to resources/templates folder') assert.isTrue(await Folder.exists(Path.resources())) assert.isTrue(await File.exists(Path.resources('templates/test.edge'))) assert.isTrue(await File.exists(Path.resources('templates/command.edge')))