diff options
author | Kevin Kragenbrink <kevin@gaikai.com> | 2015-04-20 19:10:10 +0300 |
---|---|---|
committer | Forrest L Norvell <forrest@npmjs.com> | 2015-04-24 04:16:38 +0300 |
commit | 21148620fa03a582f4ec436bb16bd472664f2737 (patch) | |
tree | b315b1221f1de3c445ec5655cf17e0e80bd72ed6 /test | |
parent | 546626059909dca1906454e820ca4e315c1795bd (diff) |
config: version tag version prefix is configurable
Includes a test and documentation.
Diffstat (limited to 'test')
-rw-r--r-- | test/tap/tag-version-prefix.js | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/test/tap/tag-version-prefix.js b/test/tap/tag-version-prefix.js new file mode 100644 index 000000000..efd2d14d4 --- /dev/null +++ b/test/tap/tag-version-prefix.js @@ -0,0 +1,88 @@ +var common = require('../common-tap.js') +var fs = require('fs') +var path = require('path') + +var mkdirp = require('mkdirp') +var osenv = require('osenv') +var rimraf = require('rimraf') +var test = require('tap').test + +var npm = require('../../lib/npm.js') + +var pkg = path.resolve(__dirname, 'version-message-config') +var cache = path.resolve(pkg, 'cache') +var npmrc = path.resolve(pkg, '.npmrc') +var packagePath = path.resolve(pkg, 'package.json') + +var json = { name: 'blah', version: '0.1.2' } + +var configContents = 'sign-git-tag=false\nmessage=":bookmark: %s"\n' + +test('npm version <semver> with message config', function (t) { + setup() + + npm.load({ prefix: pkg, userconfig: npmrc }, function () { + var git = require('../../lib/utils/git.js') + + common.makeGitRepo({ path: pkg }, function (er) { + t.ifErr(er, 'git bootstrap ran without error') + + common.npm([ + 'config', + 'set', + 'tag-version-prefix', + 'q' + ], { cwd: pkg, env: { PATH: process.env.PATH } }, + function (err, code, stdout, stderr) { + t.ifError(err, 'npm config ran without issue') + t.notOk(code, 'exited with a non-error code') + t.notOk(stderr, 'no error output') + + common.npm( + [ + 'version', + 'patch', + '--loglevel', 'silent' + // package config is picked up from env + ], + { cwd: pkg, env: { PATH: process.env.PATH } }, + function (err, code, stdout, stderr) { + t.ifError(err, 'npm version ran without issue') + t.notOk(code, 'exited with a non-error code') + t.notOk(stderr, 'no error output') + + git.whichAndExec( + ['tag'], + { cwd: pkg, env: process.env }, + function (er, tags, stderr) { + t.ok(tags.match(/q0\.1\.3/g), 'tag was created by version' + tags) + t.end() + } + ) + } + ) + }) + }) + }) +}) + +test('cleanup', function (t) { + cleanup() + t.end() +}) + +function cleanup () { + // windows fix for locked files + process.chdir(osenv.tmpdir()) + + rimraf.sync(pkg) +} + +function setup () { + cleanup() + mkdirp.sync(cache) + process.chdir(pkg) + + fs.writeFileSync(packagePath, JSON.stringify(json), 'utf8') + fs.writeFileSync(npmrc, configContents, 'ascii') +} |