This repository has been archived by the owner on Aug 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
badly-named man files won't install (fixes #7000)
Before, if you tried to put a filename in the `man` stanza of package.json that didn't follow the rules as listed in `npm help 5 package.json`, installing would work, but upgrading or uninstalling would fail with a cryptic failure. Now, fail on build with a descriptive message, and log the same descriptive message as an error (but don't fail) on unbuild.
- Loading branch information
Showing
3 changed files
with
115 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
var fs = require("fs") | ||
var resolve = require("path").resolve | ||
|
||
var osenv = require("osenv") | ||
var mkdirp = require("mkdirp") | ||
var rimraf = require("rimraf") | ||
var test = require("tap").test | ||
|
||
var common = require("../common-tap.js") | ||
|
||
var pkg = resolve(__dirname, "install-bad-man") | ||
var target = resolve(__dirname, "install-bad-man-target") | ||
|
||
var EXEC_OPTS = { | ||
cwd: target | ||
} | ||
|
||
test("setup", function (t) { | ||
setup() | ||
t.pass("setup ran") | ||
t.end() | ||
}) | ||
|
||
test("install from repo on 'OS X'", function (t) { | ||
common.npm( | ||
[ | ||
"install", | ||
"--prefix", target, | ||
"--global", | ||
pkg | ||
], | ||
EXEC_OPTS, | ||
function (err, code, stdout, stderr) { | ||
t.ifError(err, "npm command ran from test") | ||
t.equals(code, 1, "install exited with failure (1)") | ||
t.notOk(stdout, "no output indicating success") | ||
t.notOk( | ||
stderr.match(/Cannot read property '1' of null/), | ||
"no longer has cryptic error output" | ||
) | ||
t.ok( | ||
stderr.match(/install-bad-man\.1\.lol is not a valid name/), | ||
"got expected error output" | ||
) | ||
|
||
t.end() | ||
} | ||
) | ||
}) | ||
|
||
test("clean", function (t) { | ||
cleanup() | ||
t.pass("cleaned up") | ||
t.end() | ||
}) | ||
|
||
var json = { | ||
name : "install-bad-man", | ||
version : "1.2.3", | ||
man : [ "./install-bad-man.1.lol" ] | ||
} | ||
|
||
function setup () { | ||
cleanup() | ||
mkdirp.sync(pkg) | ||
// make sure it installs locally | ||
mkdirp.sync(resolve(target, "node_modules")) | ||
fs.writeFileSync( | ||
resolve(pkg, "package.json"), | ||
JSON.stringify(json, null, 2)+"\n" | ||
) | ||
fs.writeFileSync(resolve(pkg, "install-bad-man.1.lol"), "lol\n") | ||
} | ||
|
||
function cleanup () { | ||
process.chdir(osenv.tmpdir()) | ||
rimraf.sync(pkg) | ||
rimraf.sync(target) | ||
} |