3 var test = require('tape')
7 var path = require('path')
8 var spawn = require('child_process').spawn
10 var npmRun = require('../')
12 var level0 = path.join(__dirname, 'fixtures', 'level0')
13 var level1 = path.join(level0, 'node_modules', 'level1')
14 var level2 = path.join(level1, 'node_modules', 'level2')
16 var level = [level0, level1, level2]
18 var pkg = require('../package.json')
19 var npmRunBin = path.resolve(__dirname, '..', pkg.bin[pkg.name])
21 test('bin ok', function(t) {
23 t.ok(fs.existsSync(npmRunBin), 'bin exists: ' + npmRunBin)
27 test('passing dashed args', function(t) {
30 'level1 here -are --some --arguments'.split(' '),
33 var stdout = bl(function(err, data) {
34 t.equal(data.toString().trim(), 'level1')
36 var stderr = bl(function(err, data) {
37 t.equal(data.toString().trim(), 'here -are --some --arguments')
39 child.stdout.pipe(stdout)
40 child.stderr.pipe(stderr)
41 child.once('error', function(error) {
44 child.on('close', function(errCode) {
50 test('--version', function(t) {
53 '--version'.split(' '),
56 var stdout = bl(function(err, data) {
57 t.equal(data.toString().trim(), pkg.version)
59 var stderr = bl(function(err, data) {
60 t.equal(data.toString().trim(), '')
62 child.stdout.pipe(stdout)
63 child.stderr.pipe(stderr)
64 child.once('error', function(error) {
67 child.on('close', function(errCode) {
74 test('bin --version', function(t) {
77 'level1 --version'.split(' '),
80 var stdout = bl(function(err, data) {
81 t.equal(data.toString().trim(), 'level1')
83 var stderr = bl(function(err, data) {
84 t.equal(data.toString().trim(), '--version')
86 child.stdout.pipe(stdout)
87 child.stderr.pipe(stderr)
88 child.once('error', function(error) {
91 child.on('close', function(errCode) {
97 test('--help', function(t) {
103 var stdout = bl(function(err, data) {
104 t.ok(data.toString().trim().indexOf('Usage:') !== -1, 'contains usage')
106 var stderr = bl(function(err, data) {
107 t.equal(data.toString().trim(), '')
109 child.stdout.pipe(stdout)
110 child.stderr.pipe(stderr)
111 child.once('error', function(error) {
114 child.on('close', function(errCode) {
120 test('no args', function(t) {
126 var stdout = bl(function(err, data) {
127 t.ok(data.toString().trim().indexOf('Usage:') !== -1, 'contains usage')
129 var stderr = bl(function(err, data) {
130 t.equal(data.toString().trim(), '')
132 child.stdout.pipe(stdout)
133 child.stderr.pipe(stderr)
134 child.once('error', function(error) {
137 child.on('close', function(errCode) {
138 t.notEqual(errCode, 0)