Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function toGithubURL(url) {
const packageKey = last(url.split('/'))
const command = `npm info --json ${ packageKey }`
const packageInfoRaw = await execCommand(command)
const packageInfo = JSON.parse(packageInfoRaw)
if(packageInfo.error){
console.log(packageKey, 'with error')
return
}
const repoRaw = path('repository.url', packageInfo)
if (!repoRaw) return false
return remove([ 'git+', '.git' ], repoRaw)
}
function cleanTOC(input){
const removed = remove([
'- [Rambda](#rambda)',
'* [Rambda\'s advantages](#rambdas-advantages)',
], input).trim()
return removed.split('\n').map(
trim
)
.join('\n')
}
void function createReadmex(){
const content = readFileSync(OUTPUT).toString()
const [ apiRaw ] = match(/## API(.|\n)+## Benchmark/g, content)
const [ links ] = match(/## Browse by category(.|\n)+/g, content)
const api = remove('## Benchmark', apiRaw).trim()
const docsify = `${ TITLE }\n\n${ api }\n\n${ links }`
writeFileSync(OUTPUT, docsify)
}()
const withFailingTestsResults = replace(
'MARKER_FAILING_TESTS_SUMMARY',
failingTestsSummary,
withMissingRamdaMethods
)
const withBenchmarkSummary = replace(
'MARKER_BENCHMARK_SUMMARY',
benchmarkSummaryContent,
withFailingTestsResults
)
const withChangelog = inject(
changelog,
'## Changelog\n\n',
withBenchmarkSummary
)
const final = remove(
'\n* [Example use](#example-use)\n',
withChangelog
)
writeFileSync(outputPath, final)
}()
map(x => {
const replaced = replace(/(git:)|(ssh:)/, 'https:', x)
return remove('git@', replaced)
})
)
function parseMethodName(input){
if (!input.endsWith('Curried')) return input
const methodName = remove('Curried', input)
return `${ methodName } (curried)`
}
function bookmarksToLinks(output){
const content = readFileSync(FILE).toString()
const matched = match(
/href=".+" ICON/gmi,
content
)
const filtered = matched.filter(x => anyTrue(
x.includes(GITHUB_MARKER),
x.includes(NPM_MARKER),
))
const newLinks = filtered.map(
remove([ 'HREF="', /".+/g ])
).join('\n')
writeFileSync(output, newLinks)
}
\`\`\`javascript
${ CONTENT_MARKER }
\`\`\`${ NEW_LINE }
`, '\n')
const stillRawDetails = replace(CONTENT_MARKER, testContent, rawDetails)
const details = replace(new RegExp(NEW_LINE, 'gm'), '\n', stillRawDetails)
const stillRawMethodContent = replace(CONTENT_MARKER, methodContent, rawMethodContent)
const finalMethodContent = replace(new RegExp(NEW_LINE, 'gm'), '\n', stillRawMethodContent)
const withJavascriptTag = replace('```\n', '```javascript\n', input)
const withToggleDetails = replace('```\n', `\`\`\`\n\n${ details }\n`, withJavascriptTag)
const withMethodContent = replace('', `\n\n${ finalMethodContent }`, withToggleDetails)
const withoutSourceLink = remove(
/\[Source.+/,
withMethodContent
)
return withoutSourceLink
}