From ae04efbcff38f931e9c000e95569301f73bba2e2 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Sat, 18 Nov 2017 17:45:28 -0800 Subject: [PATCH] add log for keeping a file --- Readme.md | 3 ++- prune.go | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 74558b7..9e97017 100644 --- a/Readme.md +++ b/Readme.md @@ -14,9 +14,10 @@ $ node-prune • complete duration=217ms files_removed=1,222 files_total=25,520 size_removed=6.8 MB ``` + ## What? -node-prune is a small tool to prune unecessary files from ./node_modules. +node-prune is a small tool to prune unnecessary files from ./node_modules. ## Why? diff --git a/prune.go b/prune.go index e77507e..13912d4 100644 --- a/prune.go +++ b/prune.go @@ -131,7 +131,10 @@ func (p Pruner) Prune() (*Stats, error) { stats.FilesTotal++ + ctx := p.log.WithField("path", path) + if !p.prune(path, info) { + ctx.Debug("keeping") return nil } @@ -139,7 +142,7 @@ func (p Pruner) Prune() (*Stats, error) { return filepath.SkipDir } - p.log.WithField("path", path).Debug("prune") + ctx.Debug("prune") stats.FilesRemoved++ stats.SizeRemoved += info.Size()