-
Notifications
You must be signed in to change notification settings - Fork 13
/
uninstall.js
executable file
·34 lines (28 loc) · 1.05 KB
/
uninstall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const { log, success, error } = require('./utils/common');
const configs = new Map([
[ 'bash', `${process.env.HOME}/.bashrc` ],
[ 'zsh' , `${process.env.HOME}/.zshrc` ],
[ 'fish', `${process.env.HOME}/.config/fish/config.fish` ],
]);
log('Uninstalling robbyrussell theme...');
const shell = path.basename(process.env.SHELL);
const config = configs.get(shell);
log('Current shell:', shell);
log('Shell\'s config stored at:', config);
const regexp = /### GENERATED BY ROBBYRUSSELL(.|\n)*### GENERATED BY ROBBYRUSSELL/g;
try {
log(`Reading ${config}...`);
const content = fs.readFileSync(config, 'utf8');
log(`Updating ${config}...`);
// TODO: Check if theme is present in shell config
fs.writeFileSync(config, content.replace(regexp, ''), 'utf8');
success('Done! Please, reload your terminal.');
} catch (e) {
error('Something went wrong!');
error('Don\'t panic! Report an issue to:');
error('\n\thttps://github.com/denysdovhan/robbyrussell/issues/new');
throw e;
}