Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformation: current file name and exception handling #61

Open
svdoever opened this issue May 8, 2022 · 1 comment
Open

Transformation: current file name and exception handling #61

svdoever opened this issue May 8, 2022 · 1 comment

Comments

@svdoever
Copy link

svdoever commented May 8, 2022

Is there a way to determine the current file being processed within a transform? I would like to be able to do error reporting when an exception occurs within a transform, and in this error reporting mention the file being processed.

@svdoever
Copy link
Author

Found part of the solution.... there is a third argument to the transform function called config:

    interface TransformFunction {
        (content: string, options: Record<string, unknown>, config?: ProcessedConfig): string;
    }

    interface ProcessedConfig extends Configuration {
        readonly originalPath: string; // path of file being processed
        readonly originalFilePaths: string[]; // all files mathing thr glob pattern
        readonly outputDir: string; // directory where output files will be created
        readonly originalContent: string;
        readonly outputContent: string;
    }

This is incorrectly defined in the @types/markdown-magic npm package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant