Merge pull request #2279 from strapi/enhancement/auto-open

Auto open admin first start
This commit is contained in:
Jim LAURIE 2018-11-12 18:22:19 +01:00 committed by GitHub
commit 391f5b31ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 4 deletions

View File

@ -0,0 +1,3 @@
{
"init": true
}

View File

@ -11,6 +11,6 @@
"enabled": false
},
"admin": {
"autoOpen": true
"autoOpen": false
}
}

View File

@ -110,6 +110,8 @@ class Strapi extends EventEmitter {
await this.freeze();
// Update source admin.
await admin.call(this);
// Init first start
utils.init.call(this);
// Launch server.
this.server.listen(this.config.port, async (err) => {
if (err) {
@ -136,7 +138,7 @@ class Strapi extends EventEmitter {
cb();
}
if (this.config.environment === 'development' && get(this.config.currentEnvironment, 'server.admin.autoOpen', true) !== false) {
if (this.config.environment === 'development' && get(this.config.currentEnvironment, 'server.admin.autoOpen', true) !== false || this.config.init) {
await utils.openBrowser.call(this);
}
});

View File

@ -13,7 +13,8 @@ module.exports.nested = function() {
// Load root configurations.
new Promise((resolve, reject) => {
glob('./config/**/*.*(js|json)', {
cwd: this.config.appPath
cwd: this.config.appPath,
dot: true
}, (err, files) => {
if (err) {
return reject(err);

View File

@ -17,6 +17,12 @@ const exposer = require('./exposer');
const openBrowser = require('./openBrowser');
module.exports = {
init: function() {
if (this.config.init) {
fs.unlinkSync(path.resolve(this.config.appPath, 'config', '.init.json'));
}
},
loadFile: function(url) {
// Clear cache.
delete require.cache[require.resolve(path.resolve(this.config.appPath, url))];