-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path11-install-only.js
31 lines (29 loc) · 1.08 KB
/
11-install-only.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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/install-only')
const pkgJSON = require(path.join(pkg, 'package.json'))
test((t) => {
exec(`node ${bin} install --only=prod`, { 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['happy-birthday'], `${pkgJSON.name}: deps are installed`)
t.end()
})
})
})
test((t) => {
exec(`node ${bin} install --only=dev`, { 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()
})
})
})