Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

Commit

Permalink
tar: warn when using Node 6+
Browse files Browse the repository at this point in the history
Credit: @othiym23
Reviewed-By: @iarna
PR-URL: #13077
  • Loading branch information
othiym23 committed Jun 17, 2016
1 parent 7d15434 commit dff00ce
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
7 changes: 7 additions & 0 deletions lib/utils/tar.js
Expand Up @@ -17,6 +17,7 @@ var npm = require("../npm.js")
, fstream = require("fstream")
, Packer = require("fstream-npm")
, lifecycle = require("./lifecycle.js")
, semver = require('semver')

if (process.env.SUDO_UID && myUid === 0) {
if (!isNaN(process.env.SUDO_UID)) myUid = +process.env.SUDO_UID
Expand All @@ -30,6 +31,12 @@ function pack (tarball, folder, pkg, dfc, cb) {
log.verbose("tar pack", [tarball, folder])
if (typeof cb !== "function") cb = dfc, dfc = false

if (semver.gte(process.version, '6.0.0')) {
log.warn('pack', 'Publishing and packing are buggy under Node versions greater than 6.0.0.')
log.warn('pack', 'Please use Node.js LTS (4.4.x) to publish packages.')
log.warn('pack', 'See https://github.com/npm/npm/issues/5082 for details and current status.')
}

log.verbose("tarball", tarball)
log.verbose("folder", folder)

Expand Down
8 changes: 7 additions & 1 deletion test/tap/pack-scoped.js
Expand Up @@ -5,6 +5,7 @@ var fs = require("graceful-fs")
var join = require("path").join
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var semver = require("semver")

var pkg = join(__dirname, "scoped_package")
var manifest = join(pkg, "package.json")
Expand Down Expand Up @@ -66,7 +67,12 @@ test("test", function (t) {
}, function(err, code, stdout, stderr) {
t.ifErr(err, "npm pack finished without error")
t.equal(code, 0, "npm pack exited ok")
t.notOk(stderr, "got stderr data: " + JSON.stringify("" + stderr))
// https://github.com/npm/npm/pull/13077
if (semver.gte(process.version, "6.0.0")) {
t.is(stderr.trim().split(/\n/).length, 3)
} else {
t.notOk(stderr, "got stderr data: " + JSON.stringify("" + stderr))
}
stdout = stdout.trim()
var regex = new RegExp("scope-generic-package-90000.100001.5.tgz", "ig")
t.ok(stdout.match(regex), "found package")
Expand Down
8 changes: 7 additions & 1 deletion test/tap/prepublish.js
Expand Up @@ -5,6 +5,7 @@ var fs = require("graceful-fs")
var join = require("path").join
var mkdirp = require("mkdirp")
var rimraf = require("rimraf")
var semver = require("semver")

var pkg = join(__dirname, "prepublish_package")
var tmp = join(pkg, "tmp")
Expand Down Expand Up @@ -57,7 +58,12 @@ test("test", function (t) {
t.equal(code, 0, "pack finished successfully")
t.ifErr(err, "pack finished successfully")

t.notOk(stderr, "got stderr data:" + JSON.stringify("" + stderr))
// https://github.com/npm/npm/pull/13077
if (semver.gte(process.version, "6.0.0")) {
t.is(stderr.trim().split(/\n/).length, 3)
} else {
t.notOk(stderr, "got stderr data: " + JSON.stringify("" + stderr))
}
var c = stdout.trim()
var regex = new RegExp("" +
"> npm-test-prepublish@1.2.5 prepublish [^\\r\\n]+\\r?\\n" +
Expand Down
14 changes: 10 additions & 4 deletions test/tap/scripts-whitespace-windows.js
Expand Up @@ -4,6 +4,7 @@ var path = require('path')
var mkdirp = require('mkdirp')
var osenv = require('osenv')
var rimraf = require('rimraf')
var semver = require('semver')
var test = require('tap').test

var common = require('../common-tap')
Expand All @@ -21,7 +22,7 @@ var json = {
description: 'a test',
repository: 'git://github.com/robertkowalski/bogus',
scripts: {
foo: 'foo --title \"Analysis of\" --recurse -d report src'
foo: 'foo --title "Analysis of" --recurse -d report src'
},
dependencies: {
'scripts-whitespace-windows-dep': '0.0.1'
Expand All @@ -35,12 +36,12 @@ var dependency = {
bin: [ 'bin/foo' ]
}

var foo = function () {/*
var foo = function () { /*
#!/usr/bin/env node
if (process.argv.length === 8)
console.log('npm-test-fine')
*/}.toString().split('\n').slice(1, -1).join('\n')
*/ }.toString().split('\n').slice(1, -1).join('\n')

test('setup', function (t) {
cleanup()
Expand Down Expand Up @@ -72,7 +73,12 @@ test('setup', function (t) {
}, function (err, code, stdout, stderr) {
t.ifErr(err, 'npm i ' + dep + ' finished without error')
t.equal(code, 0, 'npm i ' + dep + ' exited ok')
t.notOk(stderr, 'no output stderr')
// https://github.com/npm/npm/pull/13077
if (semver.gte(process.version, '6.0.0')) {
t.is(stderr.trim().split(/\n/).length, 3)
} else {
t.notOk(stderr, 'no output stderr')
}
t.end()
})
})
Expand Down

0 comments on commit dff00ce

Please sign in to comment.