@@ -31,15 +31,16 @@ test("outdated ignores private modules", function (t) {
function () {
npm.install(".", function (err) {
t.ifError(err, "install success")
bumpLocalPrivate()
npm.outdated(function (er, d) {
t.ifError(er, "outdated success")
t.deepEqual(d, [[
path.resolve(__dirname, "outdated-private"),
"underscore",
"1.3.1",
"1.3.1",
"1.5.1",
"file:underscore"
"1.5.1",
"underscore@1.5.1"
]])
s.close()
})
@@ -70,6 +71,12 @@ var pjLocalPrivate = JSON.stringify({
private : true
}, null, 2) + "\n"

var pjLocalPrivateBumped = JSON.stringify({
name : "local-private",
version : "1.1.0",
private : true
}, null, 2) + "\n"

var pjScopedLocalPrivate = JSON.stringify({
name : "@scoped/another-local-private",
version : "1.0.0",
@@ -95,6 +102,10 @@ function bootstrap () {
fs.writeFileSync(path.resolve(pkgLocalUnderscore, "package.json"), pjLocalUnderscore)
}

function bumpLocalPrivate () {
fs.writeFileSync(path.resolve(pkgLocalPrivate, "package.json"), pjLocalPrivateBumped)
}

function cleanup () {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
@@ -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')
}
@@ -0,0 +1,82 @@
var fs = require('graceful-fs')
var http = require('http')
var path = require('path')

var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var test = require('tap').test

var pkg = path.join(__dirname, 'npm-test-unpublish-config')
var fixturePath = path.join(pkg, 'fixture_npmrc')

var common = require('../common-tap.js')

var json = {
name: 'npm-test-unpublish-config',
version: '1.2.3',
publishConfig: { registry: common.registry }
}

test('setup', function (t) {
mkdirp.sync(pkg)

fs.writeFileSync(
path.join(pkg, 'package.json'),
JSON.stringify(json), 'utf8'
)
fs.writeFileSync(
fixturePath,
'//localhost:1337/:_authToken = beeeeeeeeeeeeef\n' +
'registry = http://lvh.me:4321/registry/path\n'
)

t.end()
})

test('cursory test of unpublishing with config', function (t) {
var child
http.createServer(function (req, res) {
t.pass('got request on the fakey fake registry')
this.close()
res.statusCode = 500
res.end(JSON.stringify({
error: 'shh no tears, only dreams now'
}))
child.kill()
t.end()
}).listen(common.port, function () {
t.pass('server is listening')

child = common.npm(
[
'--userconfig', fixturePath,
'--loglevel', 'silent',
'--force',
'unpublish'
],
{
cwd: pkg,
stdio: 'inherit',
env: {
'npm_config_cache_lock_stale': 1000,
'npm_config_cache_lock_wait': 1000,
HOME: process.env.HOME,
Path: process.env.PATH,
PATH: process.env.PATH,
USERPROFILE: osenv.home()
}
},
function (err, code) {
t.ifError(err, 'publish command finished successfully')
t.notOk(code, 'npm install exited with code 0')
}
)
})
})

test('cleanup', function (t) {
process.chdir(osenv.tmpdir())
rimraf.sync(pkg)
t.end()
})