@emigrate/plugin-tools
Advanced tools
Comparing version 0.5.0 to 0.6.0
import process from 'node:process'; | ||
export const serializeError = (error) => { | ||
return { | ||
const properties = { | ||
name: error.name, | ||
message: error.message, | ||
stack: error.stack, | ||
cause: error.cause instanceof Error ? serializeError(error.cause) : error.cause, | ||
}; | ||
for (const key of Object.getOwnPropertyNames(error)) { | ||
const value = error[key]; | ||
properties[key] = value instanceof Error ? serializeError(value) : value; | ||
} | ||
return properties; | ||
}; | ||
@@ -108,10 +110,2 @@ export const isGeneratorPlugin = (plugin) => { | ||
}; | ||
const getImportFromEsm = async () => { | ||
const importFromEsm = await import('import-from-esm'); | ||
// Because of "allowSyntheticDefaultImports" we need to do this ugly hack | ||
if (importFromEsm.default) { | ||
return importFromEsm.default; | ||
} | ||
return importFromEsm; | ||
}; | ||
const loadPlugin = async (type, plugin) => { | ||
@@ -123,3 +117,3 @@ return load(plugin, ['@emigrate/plugin-', 'emigrate-plugin-', '@emigrate/'], (value) => { | ||
const load = async (name, prefixes, check) => { | ||
const importFromEsm = await getImportFromEsm(); | ||
const { default: importFromEsm } = await import('import-from-esm'); | ||
const importsToTry = name.startsWith('.') ? [name] : [...prefixes.map((prefix) => `${prefix}${name}`), name]; | ||
@@ -126,0 +120,0 @@ for await (const importPath of importsToTry) { |
@@ -7,3 +7,4 @@ export type Awaitable<T> = T | PromiseLike<T>; | ||
export type SerializedError = { | ||
name: string; | ||
[key: string]: unknown; | ||
name?: string; | ||
message: string; | ||
@@ -73,3 +74,3 @@ stack?: string; | ||
*/ | ||
onError(migration: MigrationMetadataFinished, error: SerializedError): Promise<void>; | ||
onError(migration: MigrationMetadataFinished, error: Error): Promise<void>; | ||
/** | ||
@@ -148,4 +149,5 @@ * Called when the command is finished or aborted (e.g. by a SIGTERM or SIGINT signal). | ||
duration: number; | ||
error?: SerializedError; | ||
error?: Error; | ||
}; | ||
export declare const isFinishedMigration: (migration: MigrationMetadata | MigrationMetadataFinished) => migration is MigrationMetadataFinished; | ||
export type LoaderPlugin = { | ||
@@ -152,0 +154,0 @@ /** |
@@ -1,2 +0,4 @@ | ||
export {}; | ||
export const isFinishedMigration = (migration) => { | ||
return 'status' in migration; | ||
}; | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "@emigrate/plugin-tools", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"publishConfig": { | ||
@@ -39,3 +39,3 @@ "access": "public" | ||
"dependencies": { | ||
"import-from-esm": "1.2.1" | ||
"import-from-esm": "1.3.3" | ||
}, | ||
@@ -42,0 +42,0 @@ "volta": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
65057
523
+ Addeddebug@4.4.0(transitive)
+ Addedimport-from-esm@1.3.3(transitive)
+ Addedms@2.1.3(transitive)
- Removedimport-from-esm@1.2.1(transitive)
Updatedimport-from-esm@1.3.3