remark-usage
Advanced tools
Comparing version 11.0.0 to 11.0.1
@@ -238,2 +238,3 @@ /** | ||
) | ||
/* c8 ignore next -- weird resolve errors. */ | ||
} catch {} | ||
@@ -297,3 +298,3 @@ | ||
? findExplicitExample(cwd, givenExample) | ||
: findImplicitExample(cwd) | ||
: await findImplicitExample(cwd) | ||
@@ -336,25 +337,29 @@ if (!example) { | ||
* Base. | ||
* @returns {string | undefined} | ||
* @returns {Promise<string | undefined>} | ||
* URL. | ||
*/ | ||
function findImplicitExample(cwd) { | ||
async function findImplicitExample(cwd) { | ||
const from = pathToFileURL(cwd).href + '/' | ||
const examples = [ | ||
'./example.js', | ||
'./example/index.js', | ||
'./examples.js', | ||
'./examples/index.js', | ||
'./doc/example.js', | ||
'./doc/example/index.js', | ||
'./docs/example.js', | ||
'./docs/example/index.js' | ||
'example.js', | ||
'example/index.js', | ||
'examples.js', | ||
'examples/index.js', | ||
'doc/example.js', | ||
'doc/example/index.js', | ||
'docs/example.js', | ||
'docs/example/index.js' | ||
] | ||
let index = -1 | ||
while (++index < examples.length) { | ||
const example = examples[index] | ||
try { | ||
return resolve(example, from) | ||
} catch {} | ||
try { | ||
return await Promise.any( | ||
examples.map(function (d) { | ||
const url = new URL(d, from) | ||
return fs.stat(url).then(function () { | ||
return url.href | ||
}) | ||
}) | ||
) | ||
} catch { | ||
return undefined | ||
} | ||
@@ -361,0 +366,0 @@ } |
{ | ||
"name": "remark-usage", | ||
"version": "11.0.0", | ||
"version": "11.0.1", | ||
"description": "remark plugin to add a usage example to your readme", | ||
@@ -39,3 +39,3 @@ "license": "MIT", | ||
"@types/mdast": "^4.0.0", | ||
"import-meta-resolve": "^3.0.0", | ||
"import-meta-resolve": "^4.0.0", | ||
"mdast-util-from-markdown": "^2.0.0", | ||
@@ -42,0 +42,0 @@ "mdast-util-heading-range": "^4.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
35591
932
0
+ Addedimport-meta-resolve@4.1.0(transitive)
- Removedimport-meta-resolve@3.1.1(transitive)
Updatedimport-meta-resolve@^4.0.0