1'use strict' 2var fs = require('graceful-fs') 3var path = require('path') 4var test = require('tap').test 5var Tacks = require('tacks') 6var File = Tacks.File 7var Dir = Tacks.Dir 8var common = require('../common-tap.js') 9var testdir = common.pkg 10 11var fixture = new Tacks( 12 Dir({ 13 example: Dir({ 14 }), 15 mod1: Dir({ 16 'package.json': File({ 17 name: 'mod1', 18 version: '1.0.0' 19 }) 20 }), 21 node_modules: Dir({ 22 }) 23 }) 24) 25 26function setup () { 27 fixture.create(testdir) 28} 29 30function cleanup () { 31 fixture.remove(testdir) 32} 33 34test('setup', function (t) { 35 cleanup() 36 setup() 37 t.end() 38}) 39 40function exists (file) { 41 try { 42 fs.statSync(file) 43 return true 44 } catch (ex) { 45 return false 46 } 47} 48 49test('local-args-relative-to-cwd', function (t) { 50 var instdir = path.join(testdir, 'example') 51 var config = ['--loglevel=error'] 52 common.npm(config.concat(['install', '../mod1']), {cwd: instdir}, function (err, code, stdout, stderr) { 53 if (err) throw err 54 t.comment(stdout.trim()) 55 t.comment(stderr.trim()) 56 t.is(code, 0, 'install ran ok') 57 t.ok(exists(path.join(testdir, 'node_modules', 'mod1')), 'mod1 installed') 58 t.end() 59 }) 60}) 61 62test('cleanup', function (t) { 63 cleanup() 64 t.end() 65}) 66