1 var fs = require('graceful-fs')
2 var path = require('path')
4 var mkdirp = require('mkdirp')
5 var osenv = require('osenv')
6 var rimraf = require('rimraf')
7 var test = require('tap').test
9 var common = require('../common-tap.js')
11 var pkg = path.join(__dirname, 'install-at-locally')
13 var EXEC_OPTS = { cwd: pkg }
16 name: 'install-at-locally',
20 test('setup', function (t) {
25 test('\'npm install ./package@1.2.3\' should install local pkg', function (t) {
26 var target = './package@1.2.3'
28 common.npm(['install', target], EXEC_OPTS, function (err, code) {
29 var p = path.resolve(pkg, 'node_modules/install-at-locally/package.json')
30 t.ifError(err, 'install local package successful')
31 t.equal(code, 0, 'npm install exited with code')
32 t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
37 test('\'npm install install/at/locally@./package@1.2.3\' should install local pkg', function (t) {
38 var target = 'install/at/locally@./package@1.2.3'
40 common.npm(['install', target], EXEC_OPTS, function (err, code) {
41 var p = path.resolve(pkg, 'node_modules/install-at-locally/package.json')
42 t.ifError(err, 'install local package in explicit directory successful')
43 t.equal(code, 0, 'npm install exited with code')
44 t.ok(JSON.parse(fs.readFileSync(p, 'utf8')))
49 test('cleanup', function (t) {
55 process.chdir(osenv.tmpdir())
59 function setup (target) {
61 var root = path.resolve(pkg, target)
64 path.join(root, 'package.json'),
65 JSON.stringify(json, null, 2)
67 mkdirp.sync(path.resolve(pkg, 'node_modules'))