node-version-use
Version:
Cross-platform solution for using multiple versions of node. Useful for compatibility testing
41 lines (40 loc) • 1.26 kB
JavaScript
var _process_env_OSTYPE;
import exit from 'exit-compat';
import fs from 'fs';
import { rmSync } from 'fs-remove-compat';
import path from 'path';
import { storagePath } from '../constants.js';
const isWindows = process.platform === 'win32' || /^(msys|cygwin)$/.test((_process_env_OSTYPE = process.env.OSTYPE) !== null && _process_env_OSTYPE !== void 0 ? _process_env_OSTYPE : '');
/**
* nvu teardown
*
* Remove nvu binaries from ~/.nvu/bin
*/ export default function teardownCmd(_args) {
const binDir = path.join(storagePath, 'bin');
const binaries = [
'nvu',
'node',
'npm',
'npx',
'corepack'
];
const ext = isWindows ? '.exe' : '';
let removed = 0;
for(let i = 0; i < binaries.length; i++){
const binaryPath = path.join(binDir, binaries[i] + ext);
if (fs.existsSync(binaryPath)) {
rmSync(binaryPath, {
force: true
});
removed++;
}
}
if (removed > 0) {
console.log(`Removed ${removed} binary(s) from ${binDir}`);
console.log('');
console.log('You may also want to remove ~/.nvu/bin from your PATH.');
} else {
console.log('No binaries found to remove.');
}
exit(0);
}