diff --git a/index.js b/index.js index 42d05e1..6adb935 100644 --- a/index.js +++ b/index.js @@ -137,7 +137,8 @@ class Installer { ) return BB.join( this.checkLock(), - stat && rimraf(path.join(this.prefix, 'node_modules/*')) + stat && rimraf(path.join(this.prefix, 'node_modules/*')), + stat && rimraf(path.join(this.prefix, 'node_modules/.*[0-9a-zA-Z]')) ) }).then(() => { // This needs to happen -after- we've done checkLock() diff --git a/test/specs/index.js b/test/specs/index.js index 9c4583a..cf5b626 100644 --- a/test/specs/index.js +++ b/test/specs/index.js @@ -176,6 +176,12 @@ test('deletes node_modules/ contents, without deleting node_modules/ itself', t name: 'stale-dependency', version: '1.0.0' }) + }), + '.cache': Dir({ + 'package.json': File({ + name: '.cache', + version: '1.0.0' + }) }) }), 'package.json': File({ @@ -200,7 +206,11 @@ test('deletes node_modules/ contents, without deleting node_modules/ itself', t return run().then(() => { t.ok( !fs.existsSync(path.join(nodeModulesDir, 'stale-dependency')), - 'node_modules/ contents were deleted' + 'node_modules/ contents were deleted - normal folders' + ) + t.ok( + !fs.existsSync(path.join(nodeModulesDir, '.cache')), + 'node_modules/ contents were deleted - dot folders' ) watcher.close() t.ok(notNodeModulesDeleted, 'node_modules/ itself was not deleted')