diff --git a/bin/app-configure.js b/bin/app-configure.js index 947711e..87db95e 100644 --- a/bin/app-configure.js +++ b/bin/app-configure.js @@ -62,26 +62,34 @@ function verifyConfigure(configure){ return false; } + if (!project.path || typeof project.path !== 'string') { + return false; + } + if (Array.isArray(project.env)) { - if ( - !project.env.every(function (env){ - return env.name && typeof env.name === 'string' - && env.value && typeof env.value === 'string'; - }) - ) { + var envValid = project.env.every(function (env){ + return env.name && typeof env.name === 'string' + && env.value && typeof env.value === 'string'; + }); + + if (!envValid) { return false; } + } else { + return false } if (Array.isArray(project.command)) { - if ( - !project.command.every(function (command){ - return command.name && typeof command.name === 'string' - && command.value && typeof command.value === 'string'; - }) - ) { + var commandValid = project.command.every(function (command){ + return command.name && typeof command.name === 'string' + && command.value && typeof command.value === 'string'; + }); + + if (commandValid) { return false; } + } else { + return false; } return true; diff --git a/static/js/components/app-configure/index.js b/static/js/components/app-configure/index.js index f6eadb7..eff3f94 100644 --- a/static/js/components/app-configure/index.js +++ b/static/js/components/app-configure/index.js @@ -60,7 +60,7 @@ module.exports = Vue.component('app-configure', { this.submitError = '项目已存在'; } else { this.showPopup = false; - this.configure.projects.push({ name: this.name, path: this.path }); + this.configure.projects.push({ name: this.name, path: this.path, env: [], command: [] }); this.submitError = ''; diff --git a/static/js/components/app-main/index.js b/static/js/components/app-main/index.js index 14f439c..f74f010 100644 --- a/static/js/components/app-main/index.js +++ b/static/js/components/app-main/index.js @@ -37,17 +37,7 @@ module.exports = Vue.component('app-main', { }, computed: { project: function (){ - var project = util.clone(this.projects[this.activeIndex]); - - if (!project.env) { - project.env = []; - } - - if (!project.command) { - project.command = []; - } - - return project; + return util.clone(this.projects[this.activeIndex]); }, command: function (){ return this.project.command.slice(0, 3);