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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
var common = require('../common-tap.js')
var fs = require('fs')
var path = require('path')
var mkdirp = require('mkdirp')
var test = require('tap').test
var npm = require('../../lib/npm.js')
var pkg = common.pkg
var subDirectory = path.resolve(pkg, 'sub-directory')
var packagePath = path.resolve(pkg, 'package.json')
var cache = common.cache
var json = { name: 'cat', version: '0.1.2' }
test('npm version <semver> from a subdirectory', function (t) {
mkdirp.sync(subDirectory)
process.chdir(subDirectory)
fs.writeFileSync(packagePath, JSON.stringify(json), 'utf8')
npmLoad()
function npmLoad () {
npm.load({ cache: cache }, function () {
common.makeGitRepo({
path: pkg,
added: ['package.json']
}, version)
})
}
function version (er, stdout, stderr) {
t.ifError(er, 'git repo initialized without issue')
t.notOk(stderr, 'no error output')
npm.config.set('sign-git-commit', false)
npm.config.set('sign-git-tag', false)
npm.commands.version(['patch'], checkVersion)
}
function checkVersion (er) {
var git = require('../../lib/utils/git.js')
t.ifError(er, 'version command ran without error')
git.whichAndExec(
['log'],
{ cwd: pkg, env: process.env },
checkCommit
)
}
function checkCommit (er, log, stderr) {
t.ifError(er, 'git log ran without issue')
t.notOk(stderr, 'no error output')
t.ok(log.match(/0\.1\.3/g), 'commited from subdirectory')
t.end()
}
})
|