Skip to content

Commit

Permalink
Merge pull request #168 from AthennaIO/develop
Browse files Browse the repository at this point in the history
use relative helper in template:customize
  • Loading branch information
jlenon7 authored Dec 11, 2023
2 parents af2dc4d + 9a1edb3 commit 9f5ad8e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <lenon@athenna.io>",
Expand Down
12 changes: 7 additions & 5 deletions src/commands/TemplateCustomizeCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand All @@ -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, '/')
}
}
4 changes: 2 additions & 2 deletions tests/unit/commands/TemplateCustomizeCommandTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')))
Expand Down

0 comments on commit 9f5ad8e

Please sign in to comment.