test: fix cliServiceVersion for generator unit tests

This commit is contained in:
Haoqun Jiang
2019-07-05 19:47:34 +08:00
parent 300d2aa2d4
commit 9eadfe1eba

View File

@@ -96,6 +96,13 @@ class GeneratorAPI {
}
get cliServiceVersion () {
// In generator unit tests, we don't write the actual file back to the disk.
// So there is no cli-service module to load.
// In that case, just return the cli version.
if (process.env.VUE_CLI_TEST && process.env.VUE_CLI_SKIP_WRITE) {
return this.cliVersion
}
const servicePkg = loadModule(
'@vue/cli-service/package.json',
this.generator.context