Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 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/common",
"version": "5.28.0",
"version": "5.29.0",
"description": "The Athenna common helpers to use in any Node.js ESM project.",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down
34 changes: 34 additions & 0 deletions src/helpers/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class Path extends Macroable {
seeders: 'src/database/seeders',
migrations: 'src/database/migrations',
lang: 'src/lang',
events: 'src/events',
listeners: 'src/events/listeners',
resources: 'resources',
views: 'resources/views',
locales: 'resources/locales',
Expand Down Expand Up @@ -265,6 +267,38 @@ export class Path extends Macroable {
return this
}

/**
* Return the events path of your project.
*/
public static events(subPath: string = sep): string {
return this.pwd(this.dirs.events + sep + normalize(subPath))
}

/**
* Set the directory of events folder.
*/
public static setEvents(directory: string): typeof Path {
this.dirs.events = directory

return this
}

/**
* Return the listeners path of your project.
*/
public static listeners(subPath: string = sep): string {
return this.pwd(this.dirs.listeners + sep + normalize(subPath))
}

/**
* Set the directory of listeners folder.
*/
public static setListeners(directory: string): typeof Path {
this.dirs.listeners = directory

return this
}

/**
* Return the node_modules path of your project.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/types/PathDirs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export interface PathDirs {
seeders?: string
migrations?: string
lang?: string
events?: string
listeners?: string
resources?: string
apiResources?: string
views?: string
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/helpers/PathTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ export default class PathTest {
.setSeeders('build/src/database/seeders')
.setMigrations('build/src/database/migrations')
.setLang('build/src/lang')
.setEvents('build/src/events')
.setListeners('build/src/events/listeners')
.setResources('build/resources')
.setApiResources('build/src/resources')
.setViews('build/resources/views')
Expand Down Expand Up @@ -226,6 +228,8 @@ export default class PathTest {
assert.isTrue(Path.migrations().endsWith(`build${sep}src${sep}database${sep}migrations`))
assert.isTrue(Path.resources().endsWith(`build${sep}resources`))
assert.isTrue(Path.views().endsWith(`build${sep}resources${sep}views`))
assert.isTrue(Path.events().endsWith(`build${sep}src${sep}events`))
assert.isTrue(Path.listeners().endsWith(`build${sep}src${sep}events${sep}listeners`))
assert.isTrue(Path.locales().endsWith(`build${sep}resources${sep}locales`))
assert.isTrue(Path.apiResources().endsWith(`build${sep}src${sep}resources`))
assert.isTrue(Path.nodeModules().endsWith(`build${sep}node_modules`))
Expand Down
Loading