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 download(opts) {
try {
if (typeof opts === 'string') opts = { url: opts }
const response = await fetch(opts.url, {})
let data = await response.text()
const file =
opts.file || pathUtil.basename(urlUtil.parse(opts.url).pathname)
if (await exists(file)) {
if (opts.overwrite === false) {
return Promise.resolve()
}
const localData = (await read(file)).toString()
const localLines = localData.split('\n')
const localCustomIndex = localLines.findIndex(line =>
/^# CUSTOM/i.test(line)
)
if (localCustomIndex !== -1) {
const remoteLines = data.split('\n')
const remoteCustomIndex = remoteLines.findIndex(line =>
/^# CUSTOM/i.test(line)
async function getGithubCommit(slug, fallback = 'master') {
const url = `${ghapi}/repos/${slug}/commits?${githubQueryString}`
try {
const response = await fetch(url, {
headers: {
Accept: 'application/vnd.github.v3+json'
}
})
if (response.status < 200 || response.status >= 300) {
throw await response.text()
}
const result = await response.json()
if (result.message) {
throw new Error(result.message + '\n' + url)
}
if (!result[0] || !result[0].sha) {
return fatal(
new Error(`${url} did not return the expected result`),
result
)
async function getNodeLTSVersions() {
const url =
'https://raw.githubusercontent.com/nodejs/Release/master/schedule.json'
try {
const response = await fetch(url)
const json = await response.json()
const lts = Object.entries(json)
return lts
} catch (err) {
throw new Errlop(`failed to fetch node.js LTS releases from ${url}`, err)
}
}
async function getMinimumNodeLTSVersion() {