From c63e015db12e48b9438bd8eeb22b0e26a612ecdb Mon Sep 17 00:00:00 2001 From: mchro Date: Fri, 23 Jun 2017 11:17:17 +0200 Subject: [PATCH] Always try to semver.clean(), fixes #3661 (#3702) --- .../normalize-manifest/clean version with v/actual.json | 3 +++ .../normalize-manifest/clean version with v/expected.json | 4 ++++ .../normalize-manifest/clean version with v/warnings.json | 1 + src/config.js | 2 +- src/util/normalize-manifest/fix.js | 2 +- 5 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 __tests__/fixtures/normalize-manifest/clean version with v/actual.json create mode 100644 __tests__/fixtures/normalize-manifest/clean version with v/expected.json create mode 100644 __tests__/fixtures/normalize-manifest/clean version with v/warnings.json diff --git a/__tests__/fixtures/normalize-manifest/clean version with v/actual.json b/__tests__/fixtures/normalize-manifest/clean version with v/actual.json new file mode 100644 index 0000000000..77dfc03d1a --- /dev/null +++ b/__tests__/fixtures/normalize-manifest/clean version with v/actual.json @@ -0,0 +1,3 @@ +{ + "version": "v1.0.0" +} diff --git a/__tests__/fixtures/normalize-manifest/clean version with v/expected.json b/__tests__/fixtures/normalize-manifest/clean version with v/expected.json new file mode 100644 index 0000000000..180e3d7890 --- /dev/null +++ b/__tests__/fixtures/normalize-manifest/clean version with v/expected.json @@ -0,0 +1,4 @@ +{ + "name": "", + "version": "1.0.0" +} diff --git a/__tests__/fixtures/normalize-manifest/clean version with v/warnings.json b/__tests__/fixtures/normalize-manifest/clean version with v/warnings.json new file mode 100644 index 0000000000..ca812b24c3 --- /dev/null +++ b/__tests__/fixtures/normalize-manifest/clean version with v/warnings.json @@ -0,0 +1 @@ +["No license field"] diff --git a/src/config.js b/src/config.js index e49e8583c9..24e0528a46 100644 --- a/src/config.js +++ b/src/config.js @@ -491,7 +491,7 @@ export default class Config { /** * try get the manifest file by looking - * 1. mainfest file in cache + * 1. manifest file in cache * 2. manifest file in registry */ async maybeReadManifest(dir: string, priorityRegistry?: RegistryNames, isRoot?: boolean = false): Promise { diff --git a/src/util/normalize-manifest/fix.js b/src/util/normalize-manifest/fix.js index 1b52712833..56592acbdf 100644 --- a/src/util/normalize-manifest/fix.js +++ b/src/util/normalize-manifest/fix.js @@ -32,7 +32,7 @@ export default (async function( const files = await fs.readdir(moduleLoc); // clean info.version - if (typeof info.version === 'string' && !semver.valid(info.version)) { + if (typeof info.version === 'string') { info.version = semver.clean(info.version, looseSemver) || info.version; }