Skip to content

Commit

Permalink
test: fix install check for optional deps
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgw committed Oct 7, 2018
1 parent c81df49 commit 36dd559
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/tap/install-optional-dep-identification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict'
var path = require('path')
var fs = require('graceful-fs')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var test = require('tap').test
var common = require('../common-tap.js')

var base = path.join(__dirname, path.basename(__filename, '.js'))
var moduleDir = path.join(base, 'example')
var moduleJson = {
name: 'example',
version: '1.0.0',
optionalDependencies: {
'aws-sdk': 'latest'
}
}

function setup () {
cleanup()
mkdirp.sync(moduleDir)
fs.writeFileSync(path.join(moduleDir, 'package.json'), JSON.stringify(moduleJson))
}

function cleanup () {
rimraf.sync(base)
}

test('setup', function (t) {
setup()
t.end()
})

test('optional dependency identification', function (t) {
common.npm(
['install', '--no-optional'],
{cwd: moduleDir},
function (er, code, stdout, stderr) {
t.is(code, 0, 'no error code')
t.is(stderr, '', 'no error output')
t.notOk(fs.existsSync(path.join(moduleDir, 'node_modules')), 'did not install anything')
t.end()
}
)
})

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

0 comments on commit 36dd559

Please sign in to comment.