source file comment

This commit is contained in:
dmc
2024-02-05 21:19:52 +01:00
parent 97f6a0230e
commit 14e988ffd4

View File

@@ -211,17 +211,17 @@ customElements.define('system-status', class extends HTMLElement {
}) })
}) })
} }
const comment = '# Added by Pear Runtime, configures system with Pear CLI\n'
const profiles = Object.values(this.shellProfiles) const profiles = Object.values(this.shellProfiles)
if (profiles.length > 0) { if (profiles.length > 0) {
for (const { filepath, hasPear } of profiles) { for (const { filepath, hasPear } of profiles) {
if (hasPear === false) fs.writeFileSync(filepath, '\n' + this.statement + '\n', { flag: 'a' }) if (hasPear === false) fs.writeFileSync(filepath, '\n' + comment + this.statement + '\n', { flag: 'a' })
} }
} else { } else {
const bash = this.paths.some((bin) => fs.existsSync(path.join(bin, 'bash'))) const bash = this.paths.some((bin) => fs.existsSync(path.join(bin, 'bash')))
const zsh = this.paths.some((bin) => fs.existsSync(path.join(bin, 'zsh'))) const zsh = this.paths.some((bin) => fs.existsSync(path.join(bin, 'zsh')))
fs.writeFileSync(path.join(os.homedir(), bash ? '.bashrc' : '.profile'), this.statement + '\n', { flag: 'a' }) fs.writeFileSync(path.join(os.homedir(), bash ? '.bashrc' : '.profile'), this.statement + '\n', { flag: 'a' })
if (zsh) fs.writeFileSync(path.join(os.homedir(), '.zshrc'), this.statement + '\n', { flag: 'a' }) if (zsh) fs.writeFileSync(path.join(os.homedir(), '.zshrc'), '\n' + comment + this.statement + '\n', { flag: 'a' })
} }
const pear = path.join(BIN, 'pear') const pear = path.join(BIN, 'pear')