mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
refactor: typos (#4922)
This commit is contained in:
parent
1fb9af33a3
commit
569b6aab9c
@ -198,7 +198,7 @@ export default class Builder {
|
|||||||
validateTemplate() {
|
validateTemplate() {
|
||||||
// Validate template dependencies
|
// Validate template dependencies
|
||||||
const templateDependencies = this.template.dependencies
|
const templateDependencies = this.template.dependencies
|
||||||
const dpendencyFixes = []
|
const dependencyFixes = []
|
||||||
for (const depName in templateDependencies) {
|
for (const depName in templateDependencies) {
|
||||||
const depVersion = templateDependencies[depName]
|
const depVersion = templateDependencies[depName]
|
||||||
const requiredVersion = `${depName}@${depVersion}`
|
const requiredVersion = `${depName}@${depVersion}`
|
||||||
@ -209,24 +209,24 @@ export default class Builder {
|
|||||||
const validVersion = semver.satisfies(pkg.version, depVersion)
|
const validVersion = semver.satisfies(pkg.version, depVersion)
|
||||||
if (!validVersion) {
|
if (!validVersion) {
|
||||||
consola.warn(`${requiredVersion} is required but ${depName}@${pkg.version} is installed!`)
|
consola.warn(`${requiredVersion} is required but ${depName}@${pkg.version} is installed!`)
|
||||||
dpendencyFixes.push(requiredVersion)
|
dependencyFixes.push(requiredVersion)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
consola.warn(`${depName}@${depVersion} is required but not installed!`)
|
consola.warn(`${depName}@${depVersion} is required but not installed!`)
|
||||||
dpendencyFixes.push(requiredVersion)
|
dependencyFixes.push(requiredVersion)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Suggest dependency fixes (TODO: automate me)
|
// Suggest dependency fixes (TODO: automate me)
|
||||||
if (dpendencyFixes.length) {
|
if (dependencyFixes.length) {
|
||||||
consola.error(
|
consola.error(
|
||||||
'Please install missing dependencies:\n',
|
'Please install missing dependencies:\n',
|
||||||
'\n',
|
'\n',
|
||||||
'Using yarn:\n',
|
'Using yarn:\n',
|
||||||
`yarn add ${dpendencyFixes.join(' ')}\n`,
|
`yarn add ${dependencyFixes.join(' ')}\n`,
|
||||||
'\n',
|
'\n',
|
||||||
'Using npm:\n',
|
'Using npm:\n',
|
||||||
`npm i ${dpendencyFixes.join(' ')}\n`
|
`npm i ${dependencyFixes.join(' ')}\n`
|
||||||
)
|
)
|
||||||
throw new Error('Missing Template Dependencies')
|
throw new Error('Missing Template Dependencies')
|
||||||
}
|
}
|
||||||
|
@ -111,11 +111,14 @@ export default class Resolver {
|
|||||||
throw new Error(`Cannot resolve "${path}" from "${resolvedPath}"`)
|
throw new Error(`Cannot resolve "${path}" from "${resolvedPath}"`)
|
||||||
}
|
}
|
||||||
|
|
||||||
requireModule(path, { esm, useESM = esm, alias, isAlias = alias, intropDefault } = {}) {
|
requireModule(path, { esm, useESM = esm, alias, isAlias = alias, intropDefault, interopDefault = intropDefault } = {}) {
|
||||||
let resolvedPath = path
|
let resolvedPath = path
|
||||||
let requiredModule
|
let requiredModule
|
||||||
|
|
||||||
// TODO: Remove in Nuxt 3
|
// TODO: Remove in Nuxt 3
|
||||||
|
if (intropDefault) {
|
||||||
|
consola.warn('Using intropDefault is deprecated and will be removed in Nuxt 3. Use `interopDefault` instead.')
|
||||||
|
}
|
||||||
if (alias) {
|
if (alias) {
|
||||||
consola.warn('Using alias is deprecated and will be removed in Nuxt 3. Use `isAlias` instead.')
|
consola.warn('Using alias is deprecated and will be removed in Nuxt 3. Use `isAlias` instead.')
|
||||||
}
|
}
|
||||||
@ -148,8 +151,8 @@ export default class Resolver {
|
|||||||
lastError = e
|
lastError = e
|
||||||
}
|
}
|
||||||
|
|
||||||
// Introp default
|
// Interop default
|
||||||
if (intropDefault !== false && requiredModule && requiredModule.default) {
|
if (interopDefault !== false && requiredModule && requiredModule.default) {
|
||||||
requiredModule = requiredModule.default
|
requiredModule = requiredModule.default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,14 +384,14 @@ describe('core: resolver', () => {
|
|||||||
expect(resolvedModule).toEqual('resolved module')
|
expect(resolvedModule).toEqual('resolved module')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('should require es modules without default export when intropDefault is disabled', () => {
|
test('should require es modules without default export when interopDefault is disabled', () => {
|
||||||
const resolver = new Resolver({
|
const resolver = new Resolver({
|
||||||
options: {}
|
options: {}
|
||||||
})
|
})
|
||||||
resolver.resolvePath = jest.fn()
|
resolver.resolvePath = jest.fn()
|
||||||
resolver.esm = jest.fn(() => ({ default: 'resolved module' }))
|
resolver.esm = jest.fn(() => ({ default: 'resolved module' }))
|
||||||
|
|
||||||
const resolvedModule = resolver.requireModule('/var/nuxt/resolver/module', { intropDefault: false })
|
const resolvedModule = resolver.requireModule('/var/nuxt/resolver/module', { interopDefault: false })
|
||||||
|
|
||||||
expect(resolvedModule).toEqual({ default: 'resolved module' })
|
expect(resolvedModule).toEqual({ default: 'resolved module' })
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user