Conversation
src/index.ts
Outdated
| export async function importActorProfile( | ||
| tarStream: Readable | ||
| ): Promise<Record<string, any>> { | ||
| console.log('🚀 Starting to process tar stream...') |
There was a problem hiding this comment.
Will you make it so console can be injected as an argument?
And this line like console?.log(....)
that way, by default, this function won't console.log, which is nice outside of the CLI context.
The CLI can inject in { console: globalThis.console } when it calls these functions so that, only in the cli context, this function produces logs. But then there is also a way to opt-out of verbose logging.
src/index.ts
Outdated
| } | ||
| } catch (error: any) { | ||
| reject(new Error(`Error processing file ${fileName}: ${error}`)) | ||
| console.error(`Error processing file ${fileName}:`, error.message) |
There was a problem hiding this comment.
If there is an error, imho this function should throw so the caller can catch it.
(the caller might catch it and log, but it also might not want to log).
It could also be useful to allow an onError callback to optionally be passed that gets passed with each error. If that is provided, you can call it, it can decide whether to throw or not.
But I definitely think it is always a little risky to catch an error and only log it. Would be better to throw or pass to a callback.
src/index.ts
Outdated
| stream.on('error', (error: any) => { | ||
| reject(new Error(`Stream error on file ${fileName}: ${error}`)) | ||
| console.error(`Stream error on file ${fileName}:`, error.message) | ||
| next() // Continue even on stream error |
There was a problem hiding this comment.
I think it probably makes sense to pass the error to next?
src/index.ts
Outdated
| }) | ||
|
|
||
| tarStream.on('error', (error) => { | ||
| console.error('Error in tar stream:', error.message) |
There was a problem hiding this comment.
A lot of these logs could probably be moved into cli.ts and listen for error events on the stream in there.
imho we should only console.log in the cli invocation of this function, not every time this function is called
…rove error handling, normalize file names, and skip system-generated files
…move unused options
… remove redundant console logs
e5bb242 to
89f761e
Compare
|
Resolved the rebase conflict, now its done. |
… options and error handling

No description provided.