@@ -2,7 +2,7 @@ import type { Action as ActionType } from '@stacksjs/actions'
2
2
import type { Err , Ok , Result } from '@stacksjs/error-handling'
3
3
import type { ActionOptions , CliOptions , CommandError , Readable , Subprocess , Writable } from '@stacksjs/types'
4
4
import { buddyOptions , runCommand , runCommands } from '@stacksjs/cli'
5
- import { err , handleError } from '@stacksjs/error-handling'
5
+ import { err } from '@stacksjs/error-handling'
6
6
import { log } from '@stacksjs/logging'
7
7
import * as p from '@stacksjs/path'
8
8
import { globSync } from '@stacksjs/storage'
@@ -24,25 +24,24 @@ export async function runAction(action: Action, options?: ActionOptions): Promis
24
24
// check if action is a file anywhere in ./app/Actions/**/*.ts
25
25
// if it is, return and await the action
26
26
const glob = new Bun . Glob ( '**/*.{ts,js}' )
27
- const scanOptions = { cwd : p . userActionsPath ( ) , onlyFiles : true }
27
+ const scanOptions = { cwd : p . userActionsPath ( ) , onlyFiles : true , absolute : true }
28
28
29
29
for await ( const file of glob . scan ( scanOptions ) ) {
30
- if ( file === `${ action } .ts` || file . endsWith ( `${ action } .ts` ) )
31
- return ( ( await import ( p . userActionsPath ( file ) ) ) . default as ActionType ) . handle ( )
32
-
33
- if ( file === `${ action } .js` || file . endsWith ( `${ action } .js` ) )
34
- return ( ( await import ( p . userActionsPath ( file ) ) ) . default as ActionType ) . handle ( )
30
+ if ( file . endsWith ( `${ action } .ts` ) || file . endsWith ( `${ action } .js` ) )
31
+ return ( ( await import ( file ) ) . default as ActionType ) . handle ( )
35
32
36
33
// if a custom model name is used, we need to check for it
37
34
try {
38
- const a = await import ( p . userActionsPath ( file ) )
35
+ log . debug ( 'trying to import' , file )
36
+ const a = await import ( file )
39
37
if ( a . name === action ) {
40
- console . log ( 'a.name matches' , a . name )
38
+ log . debug ( 'a.name matches' , a . name )
41
39
return await a . handle ( )
42
40
}
43
41
}
42
+ // eslint-disable-next-line unused-imports/no-unused-vars
44
43
catch ( error ) {
45
- handleError ( error )
44
+ // handleError(error, { shouldExit: false } )
46
45
}
47
46
}
48
47
0 commit comments