Skip to content

Commit

Permalink
Merge pull request #100 from AthennaIO/develop
Browse files Browse the repository at this point in the history
feat(path): add models method
  • Loading branch information
jlenon7 authored Dec 10, 2023
2 parents ae4318a + 5ffc64e commit 4e3e50e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
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": "4.21.0",
"version": "4.22.0",
"description": "The Athenna common helpers to use in any Node.js ESM project.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
17 changes: 17 additions & 0 deletions src/helpers/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class Path {
bin: 'bin',
src: 'src',
app: 'app',
models: 'app/models',
services: 'app/services',
exceptions: 'app/exceptions',
repositories: 'app/repositories',
Expand Down Expand Up @@ -526,6 +527,22 @@ export class Path {
return this
}

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

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

return this
}

/**
* Return the services' path of your project.
*/
Expand Down
1 change: 1 addition & 0 deletions src/types/PathDirs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface PathDirs {
bin?: string
src?: string
app?: string
models?: string
services?: string
exceptions?: string
repositories?: string
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/PathTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default class PathTest {

assert.equal(Path.http(), mainPath.concat(sep, 'http'))
assert.equal(Path.console(), mainPath.concat(sep, 'console'))
assert.equal(Path.models(), mainPath.concat(sep, 'models'))
assert.equal(Path.services(), mainPath.concat(sep, 'services'))
assert.equal(Path.exceptions(), mainPath.concat(sep, 'exceptions'))
assert.equal(Path.repositories(), mainPath.concat(sep, 'repositories'))
Expand Down Expand Up @@ -154,6 +155,7 @@ export default class PathTest {
Path.setBin('build/bin')
.setSrc('build/src')
.setApp('build/app')
.setModels('build/app/models')
.setServices('build/app/services')
.setExceptions('build/app/exceptions')
.setRepositories('build/app/repositories')
Expand Down Expand Up @@ -190,6 +192,7 @@ export default class PathTest {
assert.isTrue(Path.bin().endsWith(`build${sep}bin`))
assert.isTrue(Path.src().endsWith(`build${sep}src`))
assert.isTrue(Path.app().endsWith(`build${sep}app`))
assert.isTrue(Path.models().endsWith(`build${sep}app${sep}models`))
assert.isTrue(Path.services().endsWith(`build${sep}app${sep}services`))
assert.isTrue(Path.exceptions().endsWith(`build${sep}app${sep}exceptions`))
assert.isTrue(Path.repositories().endsWith(`build${sep}app${sep}repositories`))
Expand Down

0 comments on commit 4e3e50e

Please sign in to comment.