@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 +1 -1
- package/src/worker/loader.js +13 -3
package/package.json
CHANGED
package/src/worker/loader.js
CHANGED
|
@@ -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
|
|
128
|
-
const hookFile =
|
|
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', {
|
|
140
|
+
log.info( 'Hook file loaded', { specifier } );
|
|
131
141
|
}
|
|
132
142
|
}
|
|
133
143
|
};
|