-
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.
fix(test): add test for
install --save
- Loading branch information
Showing
1 changed file
with
42 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,42 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
const exec = require('child_process').exec | ||
const tree = require('strong-npm-ls') | ||
const test = require('tap').test | ||
const bin = path.join(__dirname, '..', 'bin', 'dep.js') | ||
const pkg = path.join(__dirname, 'deps/registry') | ||
const pkgJSON = require(path.join(pkg, 'package.json')) | ||
|
||
|
||
test((t) => { | ||
exec(`node ${bin} install --save=prod text-table`, {cwd: pkg}, (err, stdout, stderr) => { | ||
t.ifError(err, `${pkgJSON.name}: install ran without error`) | ||
tree.read(pkg, (err, out) => { | ||
t.ifError(err, `${pkgJSON.name}: tree could be read`) | ||
const deps = out.dependencies | ||
t.ok(deps['text-table'], `${pkgJSON.name}: deps are installed`) | ||
t.end() | ||
}) | ||
}) | ||
}) | ||
|
||
test((t) => { | ||
exec(`node ${bin} install --save=dev quack-array`, {cwd: pkg}, (err, stdout, stderr) => { | ||
t.ifError(err, `${pkgJSON.name}: install ran without error`) | ||
tree.read(pkg, (err, out) => { | ||
t.ifError(err, `${pkgJSON.name}: tree could be read`) | ||
const deps = out.devDependencies | ||
t.ok(deps['quack-array'], `${pkgJSON.name}: deps are installed`) | ||
t.end() | ||
}) | ||
}) | ||
}) | ||
|
||
|
||
test((t) => { | ||
var data = pkgJSON | ||
delete data.dependencies['text-table'] | ||
delete data.devDependencies | ||
fs.writeFileSync(path.join(pkg, 'package.json'), JSON.stringify(data, 2, 2) + '\n') | ||
t.end() | ||
}) |