1'use strict' 2var path = require('path') 3var fs = require('graceful-fs') 4var mkdirp = require('mkdirp') 5var rimraf = require('rimraf') 6var test = require('tap').test 7var common = require('../common-tap.js') 8 9var base = common.pkg 10var moduleDir = path.join(base, 'example-src') 11var destDir = path.join(base, 'example') 12var moduleJson = { 13 name: 'example', 14 version: '1.0.0' 15} 16 17function setup () { 18 cleanup() 19 mkdirp.sync(moduleDir) 20 mkdirp.sync(path.join(destDir, 'node_modules')) 21 fs.writeFileSync(path.join(moduleDir, 'package.json'), JSON.stringify(moduleJson)) 22} 23 24function cleanup () { 25 rimraf.sync(base) 26} 27 28test('setup', function (t) { 29 setup() 30 t.end() 31}) 32 33test('like-named', function (t) { 34 common.npm(['install', '../example-src'], {cwd: destDir}, function (er, code, stdout, stderr) { 35 t.is(code, 0, 'no error code') 36 t.is(stderr, '', 'no error output') 37 t.end() 38 }) 39}) 40 41test('cleanup', function (t) { 42 cleanup() 43 t.end() 44}) 45