mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 00:51:17 +00:00
29 lines
802 B
JavaScript
29 lines
802 B
JavaScript
'use strict';
|
|
|
|
// Node.js core.
|
|
const execSync = require('child_process').execSync;
|
|
|
|
// Logger.
|
|
const logger = require('strapi-utils').logger;
|
|
|
|
module.exports = (scope, success, error) => {
|
|
const Mongoose = require(`${scope.rootPath}_/node_modules/mongoose`);
|
|
|
|
Mongoose.connect(`mongodb://${ (scope.database.username && scope.database.password) ? `${scope.database.username}:${scope.database.password}@` : '' }${scope.database.host}:${scope.database.port}/${scope.database.database}`, function (err) {
|
|
if (err) {
|
|
logger.warn('Database connection failed!');
|
|
return error();
|
|
}
|
|
|
|
logger.info('Database connection is a success!');
|
|
|
|
Mongoose.connection.close();
|
|
|
|
execSync(`rm -r ${scope.rootPath}_`);
|
|
|
|
logger.info('Copying the dashboard...');
|
|
|
|
success();
|
|
});
|
|
};
|