Skip to content

Commit

Permalink
Revert "feat: add absoluteFilePath to CommandMetadata (#153)"
Browse files Browse the repository at this point in the history
This reverts commit 9bafd0b.
  • Loading branch information
Julien-R44 committed Jun 1, 2024
1 parent c44052c commit 793c0a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
15 changes: 5 additions & 10 deletions src/loaders/fs_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import { fileURLToPath } from 'node:url'
import { basename, extname, join, relative } from 'node:path'
import { basename, extname, relative } from 'node:path'
import { fsReadAll, importDefault, slash } from '@poppinss/utils'

import { validateCommand } from '../helpers.js'
Expand All @@ -35,7 +35,7 @@ export class FsLoader<Command extends AbstractBaseCommand> implements LoadersCon
/**
* An array of loaded commands
*/
#commands: { command: Command; filePath: string; absoluteFilePath: string }[] = []
#commands: { command: Command; filePath: string }[] = []

constructor(comandsDirectory: string, filter?: (filePath: string) => boolean) {
this.#comandsDirectory = comandsDirectory
Expand Down Expand Up @@ -112,16 +112,11 @@ export class FsLoader<Command extends AbstractBaseCommand> implements LoadersCon
Object.keys(commandsCollection).forEach((key) => {
const command = commandsCollection[key]
validateCommand<Command>(command, `"${key}" file`)

this.#commands.push({
command,
filePath: key,
absoluteFilePath: slash(join(this.#comandsDirectory, key)),
})
this.#commands.push({ command, filePath: key })
})

return this.#commands.map(({ command, filePath, absoluteFilePath }) => {
return Object.assign({}, command.serialize(), { filePath, absoluteFilePath })
return this.#commands.map(({ command, filePath }) => {
return Object.assign({}, command.serialize(), { filePath })
})
}

Expand Down
6 changes: 0 additions & 6 deletions tests/loaders/fs_loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { join } from 'node:path'
import { test } from '@japa/runner'
import { fileURLToPath } from 'node:url'
import { FsLoader } from '../../src/loaders/fs_loader.js'
import { slash } from '@poppinss/utils'

const BASE_URL = new URL('./tmp/', import.meta.url)
const BASE_PATH = fileURLToPath(BASE_URL)
Expand Down Expand Up @@ -75,7 +74,6 @@ test.group('Loaders | fs', (group) => {
assert.deepEqual(commands, [
{
filePath: 'make_controller_v_2.js',
absoluteFilePath: slash(join(fs.basePath, './commands/make_controller_v_2.js')),
commandName: 'make:controller',
description: '',
namespace: 'make',
Expand Down Expand Up @@ -121,7 +119,6 @@ test.group('Loaders | fs', (group) => {
{
commandName: 'make:controller',
filePath: 'make_controller.js',
absoluteFilePath: slash(join(fs.basePath, './commands/make_controller.js')),
description: '',
namespace: 'make',
args: [],
Expand Down Expand Up @@ -168,7 +165,6 @@ test.group('Loaders | fs', (group) => {
{
commandName: 'make:controller',
filePath: 'make_controller_v_3.js',
absoluteFilePath: slash(join(fs.basePath, './commands/make_controller_v_3.js')),
description: '',
namespace: 'make',
args: [],
Expand Down Expand Up @@ -255,7 +251,6 @@ test.group('Loaders | fs', (group) => {
{
commandName: 'make:controller',
filePath: 'make/controller.js',
absoluteFilePath: slash(join(fs.basePath, './commands/make/controller.js')),
description: '',
namespace: 'make',
args: [],
Expand Down Expand Up @@ -328,7 +323,6 @@ test.group('Loaders | fs', (group) => {
const commands = await loader.getMetaData()
assert.deepEqual(commands, [
{
absoluteFilePath: slash(join(fs.basePath, 'commands/make/controller.js')),
commandName: 'make:controller',
filePath: 'make/controller.js',
description: '',
Expand Down

0 comments on commit 793c0a8

Please sign in to comment.