From 793c0a8f7f815d200227501de60704b6ca80af4a Mon Sep 17 00:00:00 2001 From: Julien Ripouteau Date: Sun, 2 Jun 2024 01:27:38 +0200 Subject: [PATCH] Revert "feat: add absoluteFilePath to CommandMetadata (#153)" This reverts commit 9bafd0b8de06c675edcd577082087cc1c292e45f. --- src/loaders/fs_loader.ts | 15 +++++---------- tests/loaders/fs_loader.spec.ts | 6 ------ 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/src/loaders/fs_loader.ts b/src/loaders/fs_loader.ts index 9204b98..b2b2d2b 100644 --- a/src/loaders/fs_loader.ts +++ b/src/loaders/fs_loader.ts @@ -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' @@ -35,7 +35,7 @@ export class FsLoader 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 @@ -112,16 +112,11 @@ export class FsLoader implements LoadersCon Object.keys(commandsCollection).forEach((key) => { const command = commandsCollection[key] validateCommand(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 }) }) } diff --git a/tests/loaders/fs_loader.spec.ts b/tests/loaders/fs_loader.spec.ts index 54cdf44..716fc83 100644 --- a/tests/loaders/fs_loader.spec.ts +++ b/tests/loaders/fs_loader.spec.ts @@ -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) @@ -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', @@ -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: [], @@ -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: [], @@ -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: [], @@ -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: '',