Merge pull request #610 from strapi/fix-db-args

Fix strapi new without db args
This commit is contained in:
Jim LAURIE 2018-02-09 15:57:45 +01:00 committed by GitHub
commit 21441e41d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -29,6 +29,7 @@ const logger = require('strapi-utils').logger;
module.exports = (scope, cb) => {
// App info.
const hasDatabaseConfig = !!scope.database;
_.defaults(scope, {
name: scope.name === '.' || !scope.name ? scope.name : path.basename(process.cwd()),
author: process.env.USER || 'A Strapi developer',
@ -116,7 +117,6 @@ module.exports = (scope, cb) => {
}
])
.then(answers => {
if (hasDatabaseConfig) {
const databaseChoice = _.find(databaseChoices, ['value.database', scope.database.settings.client]);
scope.database.connector = databaseChoice.value.connector;

View File

@ -42,7 +42,15 @@ module.exports = function (name, cliArguments) {
developerMode
};
if (_.values(_.omit(cliArguments, ['dev'])).length) {
const dbArguments = ['dbclient', 'dbhost', 'dbport', 'dbname', 'dbusername', 'dbpassword'];
const matchingDbArguments = _.intersection(_.keys(cliArguments), dbArguments);
if (matchingDbArguments.length) {
if (matchingDbArguments.length !== dbArguments.length) {
logger.warn(`Some database arguments are missing. Required arguments list: ${dbArguments}`);
return process.exit(1);
}
scope.database = {
settings: {
client: cliArguments.dbclient,