diff options
Diffstat (limited to 'deps/npm/test/tap/files-and-ignores.js')
-rw-r--r-- | deps/npm/test/tap/files-and-ignores.js | 68 |
1 files changed, 61 insertions, 7 deletions
diff --git a/deps/npm/test/tap/files-and-ignores.js b/deps/npm/test/tap/files-and-ignores.js index 02371cfe3e..a8f4b222b8 100644 --- a/deps/npm/test/tap/files-and-ignores.js +++ b/deps/npm/test/tap/files-and-ignores.js @@ -5,10 +5,11 @@ var path = require('path') var rimraf = require('rimraf') var mkdirp = require('mkdirp') var fs = require('graceful-fs') +var tar = require('tar') +var zlib = require('zlib') var basepath = path.resolve(__dirname, path.basename(__filename, '.js')) var fixturepath = path.resolve(basepath, 'npm-test-files') -var modulepath = path.resolve(basepath, 'node_modules') -var installedpath = path.resolve(modulepath, 'npm-test-files') +var targetpath = path.resolve(basepath, 'target') var Tacks = require('tacks') var File = Tacks.File var Dir = Tacks.Dir @@ -459,6 +460,9 @@ test('certain files included unconditionally', function (t) { 'changelog', 'CHAngelog', 'ChangeLOG.txt', + 'history', + 'HistorY', + 'HistorY.md', 'license', 'licence', 'LICENSE', @@ -471,6 +475,9 @@ test('certain files included unconditionally', function (t) { 'changelog': File(''), 'CHAngelog': File(''), 'ChangeLOG.txt': File(''), + 'history': File(''), + 'HistorY': File(''), + 'HistorY.md': File(''), 'license': File(''), 'licence': File(''), 'LICENSE': File(''), @@ -494,6 +501,39 @@ test('certain files included unconditionally', function (t) { }) }) +test('unconditional inclusion does not capture modules', function (t) { + var fixture = new Tacks( + Dir({ + 'package.json': File({ + name: 'npm-test-files', + version: '1.2.5' + }), + 'node_modules': Dir({ + 'readme': Dir({ 'file': File('') }), + 'README': Dir({ 'file': File('') }), + 'licence': Dir({ 'file': File('') }), + 'license': Dir({ 'file': File('') }), + 'history': Dir({ 'file': File('') }), + 'History': Dir({ 'file': File('') }), + 'changelog': Dir({ 'file': File('') }), + 'ChangeLOG': Dir({ 'file': File('') }) + }) + }) + ) + withFixture(t, fixture, function (done) { + t.notOk(fileExists('node_modules/readme/file'), 'readme module not included') + t.notOk(fileExists('node_modules/README/file'), 'README module not included') + t.notOk(fileExists('node_modules/licence/file'), 'licence module not included') + t.notOk(fileExists('node_modules/license/file'), 'license module not included') + t.notOk(fileExists('node_modules/history/file'), 'history module not included') + t.notOk(fileExists('node_modules/History/file'), 'History module not included') + t.notOk(fileExists('node_modules/changelog/file'), 'changelog module not included') + t.notOk(fileExists('node_modules/ChangeLOG/file'), 'ChangeLOG module not included') + + done() + }) +}) + test('folder-based inclusion works', function (t) { var fixture = new Tacks( Dir({ @@ -534,7 +574,7 @@ test('folder-based inclusion works', function (t) { function fileExists (file) { try { - return !!fs.statSync(path.resolve(installedpath, file)) + return !!fs.statSync(path.resolve(targetpath, 'package', file)) } catch (_) { return false } @@ -542,11 +582,15 @@ function fileExists (file) { function withFixture (t, fixture, tester) { fixture.create(fixturepath) - mkdirp.sync(modulepath) - common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest) - function installCheckAndTest (err, code) { + mkdirp.sync(targetpath) + common.npm(['pack', fixturepath], {cwd: basepath}, extractAndCheck) + function extractAndCheck (err, code) { + if (err) throw err + t.is(code, 0, 'pack went ok') + extractTarball(checkTests) + } + function checkTests (err) { if (err) throw err - t.is(code, 0, 'install went ok') tester(removeAndDone) } function removeAndDone (err) { @@ -556,3 +600,13 @@ function withFixture (t, fixture, tester) { t.done() } } + +function extractTarball (cb) { + // Unpack to disk so case-insensitive filesystems are consistent + fs.createReadStream(path.join(basepath, 'npm-test-files-1.2.5.tgz')) + .pipe(zlib.Unzip()) + .on('error', cb) + .pipe(tar.Extract(targetpath)) + .on('error', cb) + .on('end', function () { cb() }) +} |