mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-19 18:51:46 -05:00
test: fix vue.config.js test for appveyor
This commit is contained in:
@@ -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)
|
||||
})
|
||||
|
||||
@@ -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.`
|
||||
|
||||
Reference in New Issue
Block a user