[READ-ONLY] Mirror of https://github.com/danielroe/uppt. A composite GitHub Action that turns conventional commits into a draft release PR, tags the PR on merge, and stages publishing to npm via OIDC
github-action
npm
npmjs
oidc
staged-publish
trusted-publishing
1export function makePkgFormatter (source: string): (pkg: unknown) => string {
2 const indentMatch = source.match(/\n([\t ]+)"/)
3 const indent: string | number = indentMatch ? indentMatch[1]! : 2
4 const usesCRLF = /\r\n/.test(source)
5 const trailingNewline = source.endsWith('\r\n') ? '\r\n' : source.endsWith('\n') ? '\n' : ''
6 return (pkg) => {
7 let out = JSON.stringify(pkg, null, indent)
8 if (usesCRLF) out = out.replace(/\n/g, '\r\n')
9 return out + trailingNewline
10 }
11}