refactor(builder): pass nuxt options to template as nuxtOptions (#5792)

This commit is contained in:
Xin Du (Clark) 2019-05-23 09:49:40 +01:00 committed by Pooya Parsa
parent 6e9cf8e394
commit 737d5f0fe7
4 changed files with 4 additions and 9 deletions

View File

@ -514,11 +514,7 @@ export default class Builder {
content = stripWhitespace(
templateFunction({
...templateVars,
...templateFile,
options: {
...templateVars.options,
...templateFile.options
}
...templateFile
})
)
} catch (err) {

View File

@ -10,7 +10,7 @@ export default class TemplateContext {
constructor(builder, options) {
this.templateFiles = Array.from(builder.template.files)
this.templateVars = {
options,
nuxtOptions: options,
extensions: options.extensions
.map(ext => ext.replace(/^\./, ''))
.join('|'),

View File

@ -371,8 +371,7 @@ describe('builder: builder generate', () => {
...templateContext.templateVars,
custom: true,
dst: 'baz.js',
src: '/var/nuxt/src/baz.js',
options: {}
src: '/var/nuxt/src/baz.js'
})
expect(stripWhitespace).toBeCalledTimes(3)
expect(stripWhitespace).nthCalledWith(1, 'compiled content')

View File

@ -38,7 +38,7 @@ TemplateContext {
"test": "test message",
},
"mode": "test mode",
"options": Object {
"nuxtOptions": Object {
"ErrorPage": "test_error_page",
"build": Object {
"splitChunks": Object {