1 var common = require('../common-tap.js')
2 var test = require('tap').test
3 var path = require('path')
5 var rimraf = require('rimraf')
6 var mkdirp = require('mkdirp')
8 var mr = require("npm-registry-mock")
10 var pkg = path.resolve(process.env.npm_config_tmp || '/tmp',
11 'noargs-install-config-save')
13 function writePackageJson() {
16 mkdirp.sync(pkg + "/cache")
18 fs.writeFileSync(pkg + "/package.json", JSON.stringify({
19 "author": "Rocko Artischocko",
29 'npm_config_save': true,
30 'npm_config_registry': common.registry,
31 'npm_config_cache': pkg + '/cache',
32 HOME: process.env.HOME,
33 Path: process.env.PATH,
34 PATH: process.env.PATH
41 test("does not update the package.json with empty arguments", function (t) {
45 mr({ port: common.port }, function (er, s) {
46 common.npm('install', OPTS, function (er, code, stdout, stderr) {
50 console.error('#', stdout)
51 console.error('#', stderr)
53 var text = JSON.stringify(fs.readFileSync(pkg + '/package.json', 'utf8'))
55 t.ok(text.indexOf("\"dependencies") === -1)
60 test("updates the package.json (adds dependencies) with an argument", function (t) {
64 mr({ port: common.port }, function (er, s) {
65 common.npm(['install', 'underscore'], OPTS, function (er, code, stdout, stderr) {
69 var text = JSON.stringify(fs.readFileSync(pkg + "/package.json", "utf8"))
70 t.ok(text.indexOf("\"dependencies") !== -1)
75 test("cleanup", function (t) {
76 rimraf.sync(pkg + "/cache")