mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +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,12 +52,13 @@ if (analyzeBuild) {
|
||||
}
|
||||
|
||||
console.log('[nuxt] Building...') // eslint-disable-line no-console
|
||||
var nuxt = new Nuxt(options)
|
||||
nuxt.build()
|
||||
.then(() => {
|
||||
console.log('[nuxt] Building done') // eslint-disable-line no-console
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err) // eslint-disable-line no-console
|
||||
process.exit(1)
|
||||
new Nuxt(options).then(nuxt => {
|
||||
nuxt.build()
|
||||
.then(() => {
|
||||
console.log('[nuxt] Building done') // eslint-disable-line no-console
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err) // eslint-disable-line no-console
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
|
17
bin/nuxt-dev
17
bin/nuxt-dev
@ -39,15 +39,16 @@ if (typeof options.rootDir !== 'string') {
|
||||
}
|
||||
options.dev = true // Add hot reloading and watching changes
|
||||
|
||||
var nuxt = new Nuxt(options)
|
||||
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)
|
||||
listenOnConfigChanges(nuxt, server)
|
||||
new Nuxt(options).then(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)
|
||||
listenOnConfigChanges(nuxt, server)
|
||||
|
||||
nuxt.build()
|
||||
.catch((err) => {
|
||||
console.error(err) // eslint-disable-line no-console
|
||||
process.exit(1)
|
||||
nuxt.build()
|
||||
.catch((err) => {
|
||||
console.error(err) // eslint-disable-line no-console
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
|
||||
function listenOnConfigChanges (nuxt, server) {
|
||||
|
@ -20,12 +20,13 @@ if (typeof options.rootDir !== 'string') {
|
||||
options.dev = false // Force production mode (no webpack middleware called)
|
||||
|
||||
console.log('[nuxt] Generating...') // eslint-disable-line no-console
|
||||
var nuxt = new Nuxt(options)
|
||||
nuxt.generate()
|
||||
.then(() => {
|
||||
console.log('[nuxt] Generate done') // eslint-disable-line no-console
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err) // eslint-disable-line no-console
|
||||
process.exit(1)
|
||||
new Nuxt(options).then(nuxt => {
|
||||
nuxt.generate()
|
||||
.then(() => {
|
||||
console.log('[nuxt] Generate done') // eslint-disable-line no-console
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err) // eslint-disable-line no-console
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
|
@ -16,10 +16,10 @@ if (typeof options.rootDir !== 'string') {
|
||||
}
|
||||
options.dev = false // Force production mode (no webpack middleware called)
|
||||
|
||||
var nuxt = new Nuxt(options)
|
||||
|
||||
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
|
||||
)
|
||||
new Nuxt(options).then(nuxt => {
|
||||
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
|
||||
)
|
||||
})
|
||||
|
@ -114,7 +114,14 @@ class Nuxt {
|
||||
this.utils = utils
|
||||
// Add module integration
|
||||
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) {
|
||||
|
@ -57,3 +57,7 @@ export function promisifyRoute (fn) {
|
||||
}
|
||||
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