feat(update): implement

Close #300
This commit is contained in:
zkochan committed 2016-10-31 19:50:55 +02:00
1 parent b6327c9812
commit a840c662e4
6 files changed
+67 -2

No files matched your search

+25 -1
View File
@@ -1,6 +1,12 @@
import path = require('path')
import test = require('tape')
import tape = require('tape')
import promisifyTape from 'tape-promise'
const test = promisifyTape(tape)
import spawn = require('cross-spawn')
import exists = require('exists-file')
import {add as addDistTag} from './support/distTags'
import prepare from './support/prepare'
import runCli from './support/run-cli'
const pnpmBin = path.join(__dirname, '../src/bin/pnpm.ts')
@@ -11,3 +17,21 @@ test('return error status code when underlying command fails', t => {
t.end()
})
test('update', async function (t) {
prepare()
const latest = 'stable'
await addDistTag('dep-of-pkg-with-1-dep', '1.0.0', latest)
await runCli('install', 'pkg-with-1-dep', '-S', '--tag', latest, '--cache-ttl', '0')
t.ok(await exists('node_modules/.store/dep-of-pkg-with-1-dep@1.0.0'), 'should install dep-of-pkg-with-1-dep@1.0.0')
await addDistTag('dep-of-pkg-with-1-dep', '1.1.0', latest)
await runCli('update', '--depth', '1', '--tag', latest)
t.ok(await exists('node_modules/.store/dep-of-pkg-with-1-dep@1.1.0'), 'should update to dep-of-pkg-with-1-dep@1.1.0')
})
+17
View File
@@ -0,0 +1,17 @@
import path = require('path')
import crossSpawn = require('cross-spawn')
const pnpmBin = path.join(__dirname, '../../src/bin/pnpm.ts')
export default function (...args: string[]) {
return new Promise((resolve, reject) => {
const proc = crossSpawn.spawn('ts-node', [pnpmBin].concat(args), {stdio: 'inherit'})
proc.on('error', reject)
proc.on('close', (code: number) => {
if (code > 0) return reject(new Error('Exit code ' + code))
resolve()
})
})
}