support directories in --file

This commit is contained in:
silverwind 2018-11-27 23:42:10 +01:00
parent 7859e5f27c
commit 58d72926ce
Signed by: silverwind
GPG Key ID: 2E62B41C93869443
2 changed files with 13 additions and 3 deletions

@ -28,7 +28,7 @@ usage: updates [options]
-s, --semver patch|minor Consider only up to given semver level
-E, --error-on-outdated Exit with error code 2 on outdated packages
-r, --registry <url> Use given registry URL
-f, --file <path> Use given package.json file
-f, --file <path> Use given package.json file or module directory
-j, --json Output a JSON object
-c, --color Force-enable color output
-n, --no-color Disable color output

@ -56,7 +56,7 @@ if (args.help) {
-s, --semver patch|minor Consider only up to given semver level
-E, --error-on-outdated Exit with error code 2 on outdated packages
-r, --registry <url> Use given registry URL
-f, --file <path> Use given package.json file
-f, --file <path> Use given package.json file or module directory
-j, --json Output a JSON object
-c, --color Force-enable color output
-n, --no-color Disable color output
@ -87,7 +87,17 @@ const greatest = parseMixedArg(args.greatest);
const prerelease = parseMixedArg(args.prerelease);
const registry = args.registry.endsWith("/") ? args.registry : args.registry + "/";
const packageFile = args.file || require("find-up").sync("package.json");
let packageFile;
if (args.file) {
if (args.file.endsWith("package.json")) {
packageFile = args.file;
} else {
packageFile = path.join(args.file, "package.json");
}
} else {
packageFile = require("find-up").sync("package.json");
}
let dependencyTypes;
if (args.types) {