Comparing version 0.7.4 to 0.8.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.COLORS = exports.OPTIONS = void 0; | ||
exports.COLORS = exports.HELP_WARNING = exports.OPTIONS = void 0; | ||
exports.OPTIONS = [ | ||
@@ -66,2 +66,3 @@ { | ||
]; | ||
exports.HELP_WARNING = 'Not all node_modules are bad! Some applications (like vscode, Discord, etc) need those dependencies to work. If their directory is deleted, the application will probably break (until the dependencies are reinstalled). NPKILL will show you these directories by highlighting them ⚠️'; | ||
exports.COLORS = { | ||
@@ -68,0 +69,0 @@ cyan: 'bgCyan', |
@@ -12,2 +12,3 @@ "use strict"; | ||
backgroundColor: 'bgBlue', | ||
warningColor: 'brightYellow', | ||
checkUpdates: true, | ||
@@ -14,0 +15,0 @@ deleteAll: false, |
@@ -14,2 +14,3 @@ "use strict"; | ||
const ansi_escapes_1 = require("ansi-escapes"); | ||
const buffer_until_1 = require("./libs/buffer-until"); | ||
class Controller { | ||
@@ -118,3 +119,3 @@ constructor(fileService, spinnerService, consoleService, updateService, resultsService) { | ||
}); | ||
this.printAt('', { | ||
this.printAt(cli_constants_1.HELP_WARNING, { | ||
x: 0, | ||
@@ -245,3 +246,4 @@ y: lineCount * 2 + 2, | ||
let { path, size } = this.getFolderTexts(folder); | ||
if (row === this.getRealCursorPosY()) { | ||
const isRowSelected = row === this.getRealCursorPosY(); | ||
if (isRowSelected) { | ||
path = colors[this.config.backgroundColor](path); | ||
@@ -251,2 +253,4 @@ size = colors[this.config.backgroundColor](size); | ||
} | ||
if (folder.isDangerous) | ||
path = colors[main_constants_1.DEFAULT_CONFIG.warningColor](path + '⚠️'); | ||
this.printAt(path, { | ||
@@ -369,2 +373,3 @@ x: main_constants_1.MARGINS.FOLDER_COLUMN_START, | ||
const params = this.prepareListDirParams(); | ||
const isChunkCompleted = (chunk) => chunk.endsWith(this.config.targetFolder + '\n'); | ||
const folders$ = this.fileService.listDir(params); | ||
@@ -378,3 +383,8 @@ folders$ | ||
throw error; | ||
}), operators_1.mergeMap((dataFolder) => rxjs_1.from(this.consoleService.splitData(dataFolder.toString()))), operators_1.filter((path) => !!path), operators_1.map((path) => ({ path, size: 0, status: 'live' })), operators_1.tap((nodeFolder) => { | ||
}), operators_1.map((buffer) => buffer.toString()), buffer_until_1.bufferUntil((chunk) => isChunkCompleted(chunk)), operators_1.mergeMap((dataFolder) => rxjs_1.from(this.consoleService.splitData(dataFolder))), operators_1.filter((path) => !!path), operators_1.map((path) => ({ | ||
path, | ||
size: 0, | ||
isDangerous: this.fileService.isDangerous(path), | ||
status: 'live', | ||
})), operators_1.tap((nodeFolder) => { | ||
this.resultsService.addResult(nodeFolder); | ||
@@ -381,0 +391,0 @@ if (this.config.sortBy === 'path') { |
@@ -25,3 +25,14 @@ "use strict"; | ||
} | ||
isDangerous(path) { | ||
/* We consider a directory to be dangerous if it is hidden. | ||
> Why dangerous? | ||
It is probable that if the node_module is included in some hidden directory, it is | ||
required by some application like "spotify", "vscode" or "Discord" and deleting it | ||
would imply breaking the application (until the dependencies are reinstalled). | ||
*/ | ||
const hiddenFilePattern = /(^|\/)\.[^\/\.]/g; | ||
return hiddenFilePattern.test(path); | ||
} | ||
} | ||
exports.FileService = FileService; |
{ | ||
"name": "npkill", | ||
"version": "0.7.4", | ||
"version": "0.8.0", | ||
"description": "List any node_modules directories in your system, as well as the space they take up. You can then select which ones you want to erase to free up space.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -81,2 +81,4 @@ <p align="center"> | ||
**Important!** Some applications installed on the system need their node_modules directory to work and deleting them may break them. NPKILL will highlight them by displaying a :warning: to be careful. | ||
<a name="options"></a> | ||
@@ -83,0 +85,0 @@ |
1905281
42
1477
243