-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.mjs
executable file
·50 lines (29 loc) · 1.14 KB
/
uninstall.mjs
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
'use strict';
import { spawnSync as spawnSyncBuiltin } from 'child_process';
import path from 'path';
import fs from 'fs';
import os from 'os';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
process.chdir(__dirname);
/**
*
* @param {string} command
* @param {...string} args
*/
function runCommand(command, ...args) {
spawnSyncBuiltin(command, args, { stdio: 'inherit', shell: true });
console.log('\n-------------------------------\n');
}
console.log(`Removing 'node-command-alias-local'`);
runCommand('npm', 'uninstall', '-g', 'node-command-alias-local');
const ncaAliasDir = path.join(os.homedir(), '.nca', 'alias');
console.log(`Removing local aliases in ${ncaAliasDir}`);
fs.rmSync(ncaAliasDir, { recursive: true, force: true });
const nodeModulesDir = path.resolve(__dirname, 'node_modules');
console.log(`Removing 'node_modules' in ${nodeModulesDir}`);
fs.rmSync(nodeModulesDir, { recursive: true, force: true });
console.log(`Removing 'node-command-alias'`);
runCommand('npm', 'uninstall', '-g', 'node-command-alias');