Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
use common.npm instead of npm.install()
Browse files Browse the repository at this point in the history
Also fixes the console output during test.
  • Loading branch information
chrismeyersfsu authored and othiym23 committed Oct 9, 2014
1 parent a8da8d6 commit 97f861c
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions test/tap/false_name.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,45 @@ var test = require("tap").test
, fs = require("fs")
, path = require("path")
, existsSync = fs.existsSync || path.existsSync
, npm = require("../../")
, rimraf = require("rimraf")
, common = require("../common-tap.js")
, mr = require("npm-registry-mock")
, pkg = path.resolve(__dirname, "false_name")
, cache = path.resolve(pkg, "cache")
, nodeModules = path.resolve(pkg, "node_modules")

test("not every pkg.name can be required", function (t) {
rimraf.sync(pkg + "/cache")
var EXEC_OPTS = { cwd: pkg }

test("setup", function(t) {
cleanup()
fs.mkdirSync(nodeModules)
t.end()
})

t.plan(1)
test("not every pkg.name can be required", function (t) {
t.plan(3)
mr(common.port, function (s) {
setup(function () {
npm.install(".", function (err) {
if (err) return t.fail(err)
s.close()
t.ok(existsSync(pkg + "/node_modules/test-package-with-one-dep/" +
"node_modules/test-package"))
})
common.npm([
"install", ".",
"--cache", cache,
"--registry", common.registry
], EXEC_OPTS, function (err, code) {
s.close()
t.ifErr(err, "install finished without error")
t.equal(code, 0, "install exited ok")
t.ok(existsSync(path.resolve(pkg,
"node_modules/test-package-with-one-dep",
"node_modules/test-package")))
})
})
})

test("cleanup", function (t) {
function cleanup() {
rimraf.sync(cache)
rimraf.sync(nodeModules)
}

test("cleanup", function (t) {
cleanup()
t.end()
})

function setup (cb) {
process.chdir(pkg)
npm.load({cache: cache, registry: common.registry},
function () {
rimraf.sync(nodeModules)
fs.mkdirSync(nodeModules)
cb()
})
}

0 comments on commit 97f861c

Please sign in to comment.