don't share options object

This commit is contained in:
Niccolo Borgioli 2023-11-16 15:13:14 +01:00
parent bc2f6242b2
commit b11f94a647
No known key found for this signature in database
GPG Key ID: D93C615F75EE4F0B

View File

@ -2,16 +2,18 @@ import fs from 'node:fs'
import path from 'node:path'
import process from 'node:process'
const defaultOptions = {
function defaultOptions() {
return {
matcher: /@import\((?<file>.+)\)(\s*?\[(?<range>\d+-\d+)\])?/g,
root: process.cwd(),
}
}
export type Options = Partial<typeof defaultOptions>
export type Options = Partial<ReturnType<typeof defaultOptions>>
export function importPlugin(md: any, options: Options = {}) {
// Options
const o = Object.assign(defaultOptions, options)
const o = Object.assign(defaultOptions(), options)
// Parser
function parse(code: string, alreadyVisited: string[] = []) {