@outputai/core 0.1.6 → 0.1.7-dev.b392109.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outputai/core",
3
- "version": "0.1.6",
3
+ "version": "0.1.7-dev.b392109.0",
4
4
  "description": "The core module of the output framework",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,5 +1,6 @@
1
1
  import { dirname, join } from 'node:path';
2
2
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
3
+ import { createRequire } from 'node:module';
3
4
  import { EOL } from 'node:os';
4
5
  import { fileURLToPath } from 'url';
5
6
  import { getTraceDestinations, sendHttpRequest } from '#internal_activities';
@@ -120,14 +121,23 @@ export async function loadWorkflows( rootDir ) {
120
121
  * @param {string} rootDir
121
122
  * @returns {void}
122
123
  */
124
+ const resolveHookFile = ( specifier, rootDir ) => {
125
+ const require = createRequire( join( rootDir, 'package.json' ) );
126
+ try {
127
+ return require.resolve( specifier );
128
+ } catch {
129
+ return join( rootDir, specifier );
130
+ }
131
+ };
132
+
123
133
  export async function loadHooks( rootDir ) {
124
134
  const packageFile = join( rootDir, 'package.json' );
125
135
  if ( existsSync( packageFile ) ) {
126
136
  const pkg = await import( packageFile, { with: { type: 'json' } } );
127
- for ( const path of pkg.default.output?.hookFiles ?? [] ) {
128
- const hookFile = join( rootDir, path );
137
+ for ( const specifier of pkg.default.output?.hookFiles ?? [] ) {
138
+ const hookFile = resolveHookFile( specifier, rootDir );
129
139
  await import( hookFile );
130
- log.info( 'Hook file loaded', { path } );
140
+ log.info( 'Hook file loaded', { specifier } );
131
141
  }
132
142
  }
133
143
  };