mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 17:37:14 +00:00
fix ~ shorthand problems
This commit is contained in:
parent
dabfe68009
commit
da725cb11e
@ -95,9 +95,9 @@ class Module {
|
|||||||
let module
|
let module
|
||||||
try {
|
try {
|
||||||
if (typeof src === 'string') {
|
if (typeof src === 'string') {
|
||||||
// Using ~ shorthand modules are resolved from project srcDir
|
// Using ~ shorthand to resolve from project srcDir
|
||||||
if (src.indexOf('~') === 0) {
|
if (src.indexOf('~') === 0) {
|
||||||
src = path.resolve(this.options.srcDir, src.substr(1))
|
src = path.resolve(this.options.srcDir, src.replace(/^~\/?/, ''))
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-eval
|
// eslint-disable-next-line no-eval
|
||||||
module = eval('require')(src)
|
module = eval('require')(src)
|
||||||
@ -107,13 +107,14 @@ class Module {
|
|||||||
console.error('[Nuxt] Unable to resolve module', src)
|
console.error('[Nuxt] Unable to resolve module', src)
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error(e)
|
console.error(e)
|
||||||
return
|
process.exit(0)
|
||||||
}
|
}
|
||||||
// Validate module
|
// Validate module
|
||||||
/* istanbul ignore if */
|
/* istanbul ignore if */
|
||||||
if (!(module instanceof Function)) {
|
if (!(module instanceof Function)) {
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
console.error('[Nuxt] Module should be a function', module)
|
console.error('[Nuxt] Module should be a function', module)
|
||||||
|
process.exit(0)
|
||||||
}
|
}
|
||||||
// Add module to this.modules
|
// Add module to this.modules
|
||||||
this.modules.push(module)
|
this.modules.push(module)
|
||||||
|
@ -25,7 +25,7 @@ class Server {
|
|||||||
let src = m
|
let src = m
|
||||||
// Using ~ shorthand to resolve from project srcDir
|
// Using ~ shorthand to resolve from project srcDir
|
||||||
if (src.indexOf('~') === 0) {
|
if (src.indexOf('~') === 0) {
|
||||||
src = path.resolve(this.nuxt.options.srcDir, src.substr(1))
|
src = path.resolve(this.nuxt.options.srcDir, src.replace(/^~\/?/, ''))
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line no-eval
|
// eslint-disable-next-line no-eval
|
||||||
m = eval('require')(src)
|
m = eval('require')(src)
|
||||||
|
Loading…
Reference in New Issue
Block a user