1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
var common = require("../common-tap.js")
var existsSync = require("fs").existsSync
var join = require("path").join
var exec = require("child_process").exec
var test = require("tap").test
var rimraf = require("rimraf")
var mkdirp = require("mkdirp")
var pkg = join(__dirname, "install-scoped")
var work = join(__dirname, "install-scoped-TEST")
var modules = join(work, "node_modules")
var EXEC_OPTS = {}
test("setup", function (t) {
mkdirp.sync(modules)
process.chdir(work)
t.end()
})
test("installing package with links", function (t) {
common.npm(["install", pkg], EXEC_OPTS, function (err, code) {
t.ifError(err, "install ran to completion without error")
t.notOk(code, "npm install exited with code 0")
t.ok(
existsSync(join(modules, "@scoped", "package", "package.json")),
"package installed"
)
t.ok(existsSync(join(modules, ".bin")), "binary link directory exists")
var hello = join(modules, ".bin", "hello")
t.ok(existsSync(hello), "binary link exists")
exec("node " + hello, function (err, stdout, stderr) {
t.ifError(err, "command ran fine")
t.notOk(stderr, "got no error output back")
t.equal(stdout, "hello blrbld\n", "output was as expected")
t.end()
})
})
})
test("cleanup", function (t) {
process.chdir(__dirname)
rimraf.sync(work)
t.end()
})
|