diff --git a/lib/publish.js b/lib/publish.js index fd3adce..81342eb 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -75,7 +75,7 @@ function putFirst (registry, data, tarbuffer, access, auth, cb) { if (!auth.token) { root.maintainers = [{ name: auth.username, email: auth.email }] - data.maintainers = JSON.parse(JSON.stringify(root.maintainers)) + data.maintainers = root.maintainers === undefined ? undefined : JSON.parse(JSON.stringify(root.maintainers)) } root.versions[ data.version ] = data @@ -173,7 +173,7 @@ function putNext (registry, newVersion, root, current, auth, cb) { current[i] = root[i] } } - var maint = JSON.parse(JSON.stringify(root.maintainers)) + var maint = root.maintainers === undefined ? undefined : JSON.parse(JSON.stringify(root.maintainers)) root.versions[newVersion].maintainers = maint var uri = url.resolve(registry, escaped(root.name)) diff --git a/test/publish.js b/test/publish.js index cb2a7a1..8ed5175 100644 --- a/test/publish.js +++ b/test/publish.js @@ -145,7 +145,7 @@ test('publish call contract', function (t) { ) t.test('malformed semver in publish', function (t) { - var metadata = JSON.parse(JSON.stringify(METADATA)) + var metadata = METADATA === undefined ? undefined : JSON.parse(JSON.stringify(METADATA)) metadata.version = '%!@#$' var params = { metadata: metadata,