clean-publish
Advanced tools
Comparing version 3.4.0 to 3.4.1
16
core.js
@@ -5,2 +5,3 @@ import { promises as fs } from "fs" | ||
import glob from 'fast-glob' | ||
import hostedGitInfo from 'hosted-git-info' | ||
@@ -128,10 +129,19 @@ import { | ||
export function getReadmeUrlFromRepository (repository) { | ||
const repoUrl = typeof repository === 'string' | ||
? repository | ||
: repository && repository.url | ||
if (repoUrl) return hostedGitInfo.fromUrl(repoUrl).docs() | ||
return null | ||
} | ||
export async function cleanDocs (drectoryName, repository) { | ||
const readmePath = join(drectoryName, 'README.md') | ||
const readme = await fs.readFile(readmePath) | ||
if (repository) { | ||
const name = repository.match(/[^/]+\/[^/]+$/) | ||
const readmeUrl = getReadmeUrlFromRepository(repository) | ||
if (readmeUrl) { | ||
const cleaned = readme.toString().split(/\n##\s*\w/m)[0] + | ||
'\n## Docs\n' + | ||
`Read **[full docs](https://github.com/${name}#readme)** on GitHub.\n` | ||
`Read **[full docs](${readmeUrl})** on GitHub.\n` | ||
await fs.writeFile(readmePath, cleaned) | ||
@@ -138,0 +148,0 @@ } |
{ | ||
"name": "clean-publish", | ||
"version": "3.4.0", | ||
"version": "3.4.1", | ||
"description": "Clean your package before publish", | ||
@@ -26,4 +26,5 @@ "keywords": [ | ||
"fs-extra": "^10.0.0", | ||
"hosted-git-info": "^4.0.2", | ||
"lilconfig": "^2.0.3" | ||
} | ||
} |
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
21243
630
5
+ Addedhosted-git-info@^4.0.2
+ Addedhosted-git-info@4.1.0(transitive)
+ Addedlru-cache@6.0.0(transitive)
+ Addedyallist@4.0.0(transitive)