refactor(@embark/template_generator): account for prerelease in embark version

If the version in the embark package's own `package.json` has a prerelease
identifier then appending `.x` to the major version isn't viable for resolving
the latest version of the template package that's in the same prerelease line;
a more complex semver range must be used:

```
"${pkg}@^${major}.${minor}.${patch}- <${major}.${minor}.${patch}"
```
This commit is contained in:
Michael Bradley, Jr 2019-10-28 10:24:55 -05:00 committed by Michael Bradley
parent 1225cb14e8
commit db66f0e197

View File

@ -125,8 +125,13 @@ class TemplateGenerator {
() => (pkgJsonPath) => normalize(pkgJsonPath).includes(normalize('dapps/templates')) () => (pkgJsonPath) => normalize(pkgJsonPath).includes(normalize('dapps/templates'))
); );
} else { } else {
const version = fs.readJSONSync(embarkPath('package.json')).version; const version = semver(fs.readJSONSync(embarkPath('package.json')).version);
templateSpecifier = `${templatePkg}@${semver(version).major}.x`; if (!version.prerelease.length) {
templateSpecifier = `${templatePkg}@${version.major}.x`;
} else {
const majorMinorPatch = `${version.major}.${version.minor}.${version.patch}`;
templateSpecifier = `"${templatePkg}@^${majorMinorPatch}- <${majorMinorPatch}"`;
}
} }
const tmpDir = require('fs-extra').mkdtempSync( const tmpDir = require('fs-extra').mkdtempSync(