import fs from 'fs' import path from 'path' import { config } from 'pear' const pearBin = path.join(config.pearDir, 'bin') const paths = process.env.PATH.split(path.delimiter) customElements.define('system-status', class extends HTMLElement { constructor () { super() this.vianode = false this.installed = paths.some((p) => { if (p.includes('node') && p.includes('bin')) this.vianode = fs.existsSync(path.join(p, 'pear')) return p === pearBin }) this.template = document.createElement('template') this.template.innerHTML = `

System Status

${ this.installed ? `

Pear is installed.

✔ Pear is in the system PATH and ready to go.

` : `

Pear setup is nearly complete.

Click the button to add ${pearBin} to the system PATH

` }
` this.root = this.attachShadow({ mode: 'open' }) this.root.appendChild(this.template.content.cloneNode(true)) this.button = this.root.querySelector('button') if (this.button) { const listener = () => { this.button.removeEventListener('click', listener) } this.button.addEventListener('click', listener) } } })