Skip to content

Commit

Permalink
feat(path): add jobs and workers path
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed May 14, 2024
1 parent 26a70d7 commit c221b14
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 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/common",
"version": "4.39.0",
"version": "4.40.0",
"description": "The Athenna common helpers to use in any Node.js ESM project.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
34 changes: 34 additions & 0 deletions src/helpers/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export class Path {
app: 'app',
models: 'app/models',
services: 'app/services',
jobs: 'app/jobs',
workers: 'app/workers',
exceptions: 'app/exceptions',
repositories: 'app/repositories',
console: 'app/console',
Expand Down Expand Up @@ -560,6 +562,38 @@ export class Path {
return this
}

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

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

return this
}

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

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

return this
}

/**
* Return the repositories' 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 @@ -13,6 +13,8 @@ export interface PathDirs {
app?: string
models?: string
services?: string
jobs?: string
workers?: string
exceptions?: string
repositories?: string
console?: string
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/PathTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export default class PathTest {
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.jobs(), mainPath.concat(sep, 'jobs'))
assert.equal(Path.workers(), mainPath.concat(sep, 'workers'))
assert.equal(Path.validators(), mainPath.concat(sep, 'validators'))
assert.equal(Path.exceptions(), mainPath.concat(sep, 'exceptions'))
assert.equal(Path.repositories(), mainPath.concat(sep, 'repositories'))
Expand Down Expand Up @@ -158,6 +160,8 @@ export default class PathTest {
.setApp('build/app')
.setModels('build/app/models')
.setServices('build/app/services')
.setJobs('build/app/jobs')
.setWorkers('build/app/workers')
.setValidators('build/app/validators')
.setExceptions('build/app/exceptions')
.setRepositories('build/app/repositories')
Expand Down Expand Up @@ -196,6 +200,8 @@ export default class PathTest {
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.jobs().endsWith(`build${sep}app${sep}jobs`))
assert.isTrue(Path.workers().endsWith(`build${sep}app${sep}workers`))
assert.isTrue(Path.validators().endsWith(`build${sep}app${sep}validators`))
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 c221b14

Please sign in to comment.