1 var exec = require('child_process').exec
2 var fs = require('graceful-fs')
3 var path = require('path')
4 var existsSync = fs.existsSync || path.existsSync
6 var mkdirp = require('mkdirp')
7 var osenv = require('osenv')
8 var rimraf = require('rimraf')
9 var test = require('tap').test
11 var common = require('../common-tap.js')
13 var pkg = path.join(__dirname, 'install-scoped-link')
14 var work = path.join(__dirname, 'install-scoped-link-TEST')
15 var modules = path.join(work, 'node_modules')
17 var EXEC_OPTS = { cwd: work }
19 var world = 'console.log("hello blrbld")\n'
22 name: '@scoped/package',
29 test('setup', function (t) {
33 path.join(pkg, 'package.json'),
34 JSON.stringify(json, null, 2)
36 fs.writeFileSync(path.join(pkg, 'world.js'), world)
44 test('installing package with links', function (t) {
47 '--loglevel', 'silent',
51 function (err, code) {
52 t.ifError(err, 'install ran to completion without error')
53 t.notOk(code, 'npm install exited with code 0')
56 existsSync(path.join(modules, '@scoped', 'package', 'package.json')),
59 t.ok(existsSync(path.join(modules, '.bin')), 'binary link directory exists')
61 var hello = path.join(modules, '.bin', 'hello')
62 t.ok(existsSync(hello), 'binary link exists')
64 exec('node ' + hello, function (err, stdout, stderr) {
65 t.ifError(err, 'command ran fine')
66 t.notOk(stderr, 'got no error output back')
67 t.equal(stdout, 'hello blrbld\n', 'output was as expected')
75 test('cleanup', function (t) {
81 process.chdir(osenv.tmpdir())