mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 18:13:54 +00:00
Install all modules in sequence before nuxt init
For this functionality Nuxt constructor would return a Promise so all bin commands updated to resolve promise before using nuxt
This commit is contained in:
parent
5039459f06
commit
497d673727
@ -52,7 +52,7 @@ if (analyzeBuild) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('[nuxt] Building...') // eslint-disable-line no-console
|
console.log('[nuxt] Building...') // eslint-disable-line no-console
|
||||||
var nuxt = new Nuxt(options)
|
new Nuxt(options).then(nuxt => {
|
||||||
nuxt.build()
|
nuxt.build()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log('[nuxt] Building done') // eslint-disable-line no-console
|
console.log('[nuxt] Building done') // eslint-disable-line no-console
|
||||||
@ -61,3 +61,4 @@ nuxt.build()
|
|||||||
console.error(err) // eslint-disable-line no-console
|
console.error(err) // eslint-disable-line no-console
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
@ -39,7 +39,7 @@ if (typeof options.rootDir !== 'string') {
|
|||||||
}
|
}
|
||||||
options.dev = true // Add hot reloading and watching changes
|
options.dev = true // Add hot reloading and watching changes
|
||||||
|
|
||||||
var nuxt = new Nuxt(options)
|
new Nuxt(options).then(nuxt => {
|
||||||
var server = new nuxt.Server(nuxt)
|
var server = new nuxt.Server(nuxt)
|
||||||
.listen(process.env.PORT || process.env.npm_package_config_nuxt_port, process.env.HOST || process.env.npm_package_config_nuxt_host)
|
.listen(process.env.PORT || process.env.npm_package_config_nuxt_port, process.env.HOST || process.env.npm_package_config_nuxt_host)
|
||||||
listenOnConfigChanges(nuxt, server)
|
listenOnConfigChanges(nuxt, server)
|
||||||
@ -49,6 +49,7 @@ nuxt.build()
|
|||||||
console.error(err) // eslint-disable-line no-console
|
console.error(err) // eslint-disable-line no-console
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
function listenOnConfigChanges (nuxt, server) {
|
function listenOnConfigChanges (nuxt, server) {
|
||||||
// Listen on nuxt.config.js changes
|
// Listen on nuxt.config.js changes
|
||||||
|
@ -20,7 +20,7 @@ if (typeof options.rootDir !== 'string') {
|
|||||||
options.dev = false // Force production mode (no webpack middleware called)
|
options.dev = false // Force production mode (no webpack middleware called)
|
||||||
|
|
||||||
console.log('[nuxt] Generating...') // eslint-disable-line no-console
|
console.log('[nuxt] Generating...') // eslint-disable-line no-console
|
||||||
var nuxt = new Nuxt(options)
|
new Nuxt(options).then(nuxt => {
|
||||||
nuxt.generate()
|
nuxt.generate()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
console.log('[nuxt] Generate done') // eslint-disable-line no-console
|
console.log('[nuxt] Generate done') // eslint-disable-line no-console
|
||||||
@ -29,3 +29,4 @@ nuxt.generate()
|
|||||||
console.error(err) // eslint-disable-line no-console
|
console.error(err) // eslint-disable-line no-console
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
@ -16,10 +16,10 @@ if (typeof options.rootDir !== 'string') {
|
|||||||
}
|
}
|
||||||
options.dev = false // Force production mode (no webpack middleware called)
|
options.dev = false // Force production mode (no webpack middleware called)
|
||||||
|
|
||||||
var nuxt = new Nuxt(options)
|
new Nuxt(options).then(nuxt => {
|
||||||
|
|
||||||
new nuxt.Server(nuxt)
|
new nuxt.Server(nuxt)
|
||||||
.listen(
|
.listen(
|
||||||
process.env.PORT || process.env.npm_package_config_nuxt_port,
|
process.env.PORT || process.env.npm_package_config_nuxt_port,
|
||||||
process.env.HOST || process.env.npm_package_config_nuxt_host
|
process.env.HOST || process.env.npm_package_config_nuxt_host
|
||||||
)
|
)
|
||||||
|
})
|
||||||
|
@ -114,7 +114,14 @@ class Nuxt {
|
|||||||
this.utils = utils
|
this.utils = utils
|
||||||
// Add module integration
|
// Add module integration
|
||||||
this.module = new Module(this)
|
this.module = new Module(this)
|
||||||
return this
|
// Install all modules in sequence and then return `this` instance
|
||||||
|
return utils.sequence(options.modules, this.module.installModule.bind(this.module))
|
||||||
|
.then(() => this)
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('[nuxt] error while initializing modules') // eslint-disable-line no-console
|
||||||
|
console.error(err) // eslint-disable-line no-console
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
close (callback) {
|
close (callback) {
|
||||||
|
@ -57,3 +57,7 @@ export function promisifyRoute (fn) {
|
|||||||
}
|
}
|
||||||
return promise
|
return promise
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function sequence (tasks, fn) {
|
||||||
|
return tasks.reduce((promise, task) => promise.then(() => fn(task)), Promise.resolve())
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user