← back to humanspeak__svelte-motion

Function bodies 3 total

All specs Real LLM only Function bodies
readPkgName function · javascript · L21-L28 (8 LOC)
scripts/dev-urls.mjs
function readPkgName(dir) {
    try {
        const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'))
        return pkg.name || dir
    } catch {
        return dir
    }
}
copyToClipboard function · javascript · L31-L39 (9 LOC)
scripts/dev-urls.mjs
function copyToClipboard(text) {
    const cmd =
        process.platform === 'darwin'
            ? 'pbcopy'
            : process.platform === 'win32'
              ? 'clip'
              : 'xclip -selection clipboard'
    execSync(cmd, { input: text })
}
printTable function · javascript · L96-L121 (26 LOC)
scripts/dev-urls.mjs
function printTable(statusLine = '') {
    console.clear()
    console.log()
    console.log(`${BOLD}  Dev servers${RESET}`)
    console.log(`${DIM}  ${'─'.repeat(50)}${RESET}`)

    if (entries.length === 0) {
        console.log('  No dev server ports discovered.')
    } else {
        const maxName = Math.max(...entries.map((e) => e.name.length))
        entries.forEach(({ name, port }, i) => {
            const url = `http://localhost:${port}`
            console.log(
                `  ${YELLOW}[${i + 1}]${RESET}  ${GREEN}●${RESET}  ${name.padEnd(maxName)}  ${CYAN}${url}${RESET}`
            )
        })
    }

    console.log(`${DIM}  ${'─'.repeat(50)}${RESET}`)
    if (statusLine) {
        console.log(`  ${statusLine}`)
    } else {
        console.log(`${DIM}  Press 1-${entries.length} to copy URL to clipboard${RESET}`)
    }
    console.log()
}