]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/test/tap/legacy-ignore-nested-nm.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / test / tap / legacy-ignore-nested-nm.js
1 'use strict'
2 var test = require('tap').test
3 var common = require('../common-tap.js')
4 var path = require('path')
5 var rimraf = require('rimraf')
6 var mkdirp = require('mkdirp')
7 var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))
8 var fixturepath = path.resolve(basepath, 'npm-test-ignore-nested-nm')
9 var modulepath = path.resolve(basepath, 'node_modules')
10 var installedpath = path.resolve(modulepath, 'npm-test-ignore-nested-nm')
11 var fs = require('graceful-fs')
12 var Tacks = require('tacks')
13 var File = Tacks.File
14 var Dir = Tacks.Dir
15
16 var fileData = 'I WILL NOT BE IGNORED!\n'
17 var fixture = new Tacks(
18   Dir({
19     lib: Dir({
20       node_modules: Dir({
21         foo: File(fileData)
22       })
23     }),
24     'package.json': File({
25       name: 'npm-test-ignore-nested-nm',
26       version: '1.2.5'
27     })
28   })
29 )
30 test('setup', function (t) {
31   setup()
32   t.done()
33 })
34 test('ignore-nested-nm', function (t) {
35   common.npm(['install', fixturepath], {cwd: basepath}, installCheckAndTest)
36   function installCheckAndTest (err, code, stdout, stderr) {
37     if (err) throw err
38     t.is(code, 0, 'install went ok')
39     var foopath = path.resolve(installedpath, 'lib/node_modules/foo')
40     fs.readFile(foopath, function (err, data) {
41       t.ifError(err, 'file read successfully')
42       t.equal(data.toString(), fileData)
43       common.npm(['rm', fixturepath], {cwd: basepath}, removeCheckAndDone)
44     })
45   }
46   function removeCheckAndDone (err, code, stdout, stderr) {
47     if (err) throw err
48     t.is(code, 0, 'remove went ok')
49     t.done()
50   }
51 })
52 test('cleanup', function (t) {
53   cleanup()
54   t.done()
55 })
56 function setup () {
57   cleanup()
58   fixture.create(fixturepath)
59   mkdirp.sync(modulepath)
60 }
61 function cleanup () {
62   fixture.remove(fixturepath)
63   rimraf.sync(basepath)
64 }