-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix install check for optional deps
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
}) |