1
0
mirror of synced 2025-12-21 19:06:49 -05:00
Files
docs/script/deployment/create-staging-app-name.js
Kevin Heis 8a56437c93 Pretty format (#20352)
* Update prettier flow to include JS

* Run prettier

* ...run prettier
2021-07-14 14:35:01 -07:00

20 lines
521 B
JavaScript

#!/usr/bin/env node
import xGithubSlugger from 'github-slugger'
const slugify = xGithubSlugger.slug
const APP_NAME_MAX_LENGTH = 30
export default function ({ repo, pullNumber, branch }) {
return (
`${repo}-${pullNumber}--${slugify(branch)}`
// Shorten the string to the max allowed length
.slice(0, APP_NAME_MAX_LENGTH)
// Convert underscores to dashes
.replace(/_/g, '-')
// Remove trailing dashes
.replace(/-+$/, '')
// Make it all lowercase
.toLowerCase()
)
}