From a3a2fb97adc87c2aa9b2b8957861b30efafc7ad0 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Fri, 19 Aug 2016 11:20:35 -0700 Subject: [PATCH] tar: ignore *.orig files Credit: @boneskull PR-URL: https://github.com/npm/npm/pull/13708 Reviewed-By: @zkat --- doc/files/package.json.md | 1 + lib/utils/tar.js | 3 ++- test/tap/files-and-ignores.js | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/files/package.json.md b/doc/files/package.json.md index 98b77af3e53..c67dfa419ea 100644 --- a/doc/files/package.json.md +++ b/doc/files/package.json.md @@ -203,6 +203,7 @@ Conversely, some files are always ignored: * `.npmrc` * `node_modules` * `config.gypi` +* `*.orig` ## main diff --git a/lib/utils/tar.js b/lib/utils/tar.js index 0122a96f70c..f580c8e05de 100644 --- a/lib/utils/tar.js +++ b/lib/utils/tar.js @@ -102,7 +102,8 @@ BundledPacker.prototype.applyIgnores = function (entry, partial, entryObj) { entry === '.npmrc' || entry.match(/^\..*\.swp$/) || entry === '.DS_Store' || - entry.match(/^\._/) + entry.match(/^\._/) || + entry.match(/^.*\.orig$/) ) { return false } diff --git a/test/tap/files-and-ignores.js b/test/tap/files-and-ignores.js index a8f4b222b89..88d9d12922b 100644 --- a/test/tap/files-and-ignores.js +++ b/test/tap/files-and-ignores.js @@ -404,7 +404,8 @@ test('certain files ignored unconditionally', function (t) { '.npmrc', '.foo.swp', '.DS_Store', - '._ohno' + '._ohno', + 'foo.orig' ] }), '.git': Dir({foo: File('')}), @@ -421,7 +422,8 @@ test('certain files ignored unconditionally', function (t) { '.foo.swp': File(''), '.DS_Store': Dir({foo: File('')}), '._ohno': File(''), - '._ohnoes': Dir({noes: File('')}) + '._ohnoes': Dir({noes: File('')}), + 'foo.orig': File('') }) ) withFixture(t, fixture, function (done) { @@ -440,6 +442,7 @@ test('certain files ignored unconditionally', function (t) { t.notOk(fileExists('.DS_Store'), '.DS_Store not included') t.notOk(fileExists('._ohno'), '._ohno not included') t.notOk(fileExists('._ohnoes'), '._ohnoes not included') + t.notOk(fileExists('foo.orig'), 'foo.orig not included') done() }) })