You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
carbon/release.js

37 lines
724 B
JavaScript

const url = require('url')
const clipboardy = require('clipboardy')
module.exports = async markdown => {
let URL = process.env.URL || process.env.NOW_URL || clipboardy.readSync()
if (!URL.startsWith('http')) {
URL = 'https://' + URL
}
const { host } = url.parse(URL)
if (host) {
let name
try {
name = require('./now.json').name
} catch (e) {
/* pass */
}
if (!name) {
try {
name = require('./package.json').name
} catch (e) {
/* pass */
}
}
const prefix = name ? `\`${name}\`: ` : ''
return [`${prefix}https://${host}`, '', markdown].join('\n')
}
// Use the available data to create a custom release
return markdown
}