test: fix vue.config.js test for appveyor

This commit is contained in:
Evan You
2018-02-28 18:51:36 -05:00
parent 3489e4d0af
commit e4ff22a4de
2 changed files with 6 additions and 2 deletions

View File

@@ -53,6 +53,7 @@ test('load project options from package.json', () => {
})
test('load project options from vue.config.js', () => {
process.env.VUE_CLI_SERVICE_CONFIG_PATH = `/vue.config.js`
fs.writeFileSync('/vue.config.js', `module.exports = { lintOnSave: false }`)
mockPkg({
vue: {
@@ -61,6 +62,7 @@ test('load project options from vue.config.js', () => {
})
const service = createMockService()
fs.unlinkSync('/vue.config.js')
delete process.env.VUE_CLI_SERVICE_CONFIG_PATH
// vue.config.js has higher priority
expect(service.projectOptions.lintOnSave).toBe(false)
})

View File

@@ -159,11 +159,13 @@ module.exports = class Service {
loadProjectOptions (inlineOptions) {
// vue.config.js
let fileConfig, pkgConfig, resolved, resovledFrom
const configPath = path.resolve(this.context, 'vue.config.js')
const configPath = (
process.env.VUE_CLI_SERVICE_CONFIG_PATH ||
path.resolve(this.context, 'vue.config.js')
)
if (fs.existsSync(configPath)) {
try {
fileConfig = require(configPath)
console.log(fileConfig)
if (!fileConfig || typeof fileConfig !== 'object') {
error(
`Error loading ${chalk.bold('vue.config.js')}: should export an object.`