Files
pnpm/test/cli.ts
Zoltan Kochan 2c46333107 fix: global installation always works now (#713)
* fix: global installation always works now

Close #711

* refactor: avoid using `read-pkg-up`

BREAKING CHANGE:

API should be called in the folder that has a package.json file.
pnpm won't search up for a package.json file.

Close #67

* docs(API): update

* refactor: write-pkg created dir on its own

* refactor: rename `globalDir` to `globalPrefix`

* feat: saving the global package in <global prefix>/pnpm-global
2017-04-22 23:11:25 +03:00

72 lines
1.9 KiB
TypeScript

import path = require('path')
import tape = require('tape')
import promisifyTape from 'tape-promise'
const test = promisifyTape(tape)
import spawn = require('cross-spawn')
import exists = require('path-exists')
import mkdirp = require('mkdirp-promise')
import {
prepare,
addDistTag,
execPnpm,
execPnpmSync,
} from './utils'
test('return error status code when underlying command fails', t => {
const result = execPnpmSync('invalid-command')
t.equal(result.status, 1, 'error status code returned')
t.end()
})
test('installs in the folder where the package.json file is', async function (t) {
const project = prepare(t)
await mkdirp('subdir')
process.chdir('subdir')
await execPnpm('install', 'rimraf@2.5.1')
const rimraf = project.requireModule('rimraf')
t.ok(typeof rimraf === 'function', 'rimraf() is available')
await project.isExecutable('.bin/rimraf')
})
test('update', async function (t) {
const project = prepare(t)
await addDistTag('dep-of-pkg-with-1-dep', '100.0.0', 'latest')
await execPnpm('install', 'pkg-with-1-dep', '-S')
await project.storeHas('dep-of-pkg-with-1-dep', '100.0.0')
await addDistTag('dep-of-pkg-with-1-dep', '100.1.0', 'latest')
await execPnpm('update', '--depth', '1')
await project.storeHas('dep-of-pkg-with-1-dep', '100.1.0')
})
test('installation via the CLI', async function (t) {
const project = prepare(t)
const result = execPnpmSync('install', 'rimraf@2.5.1')
t.equal(result.status, 0, 'install successful')
const rimraf = project.requireModule('rimraf')
t.ok(typeof rimraf === 'function', 'rimraf() is available')
await project.isExecutable('.bin/rimraf')
})
test('pass through to npm CLI for commands that are not supported by npm', t => {
const result = execPnpmSync('config', 'get', 'user-agent')
t.equal(result.status, 0, 'command was successfull')
t.ok(result.stdout.toString().indexOf('npm/') !== -1, 'command returned correct result')
t.end()
})