elviss 2 rokov pred
rodič
commit
52f995a16a
2 zmenil súbory, kde vykonal 10 pridanie a 10 odobranie
  1. 7 5
      src/PackageClass.php
  2. 3 5
      src/Utility.php

+ 7 - 5
src/PackageClass.php

@@ -100,13 +100,15 @@ class PackageClass
 		
 		//获取部署配置信息
 		$cfgPath = pathJoin($distributeDir,'config.json');
-		$config = loadConfig($cfgPath);
-		if(!$config){
-			printf("Failed to load distribute config -- %s\n",$cfgPath);
+		if(! file_exists($cfgPath) ){
+			logError("distribute config file not exists",$cfgPath);
+			return false;
+		}
+		self::$config = loadConfig($cfgPath);
+		if(!self::$config){
+			logError("Failed to load distribute config",$cfgPath);
 			return false;
 		}
-		self::$config = $config;
-
 		return true;
 	}
 	

+ 3 - 5
src/Utility.php

@@ -8,10 +8,11 @@ function logInfo(){
 		$content .= $args[$i] . ' ';
 	}
 	$content .= PHP_EOL;
+	print($content);
 	file_put_contents(LOG_PATH, $content, FILE_APPEND);
 }
 //记录错误日志
-function logError($content){
+function logError(){
 	$content = '[ERR]';
 	$args = func_get_args();
 	$argc = func_num_args();
@@ -19,6 +20,7 @@ function logError($content){
 		$content .= $args[$i] . ' ';
 	}
 	$content .= PHP_EOL;
+	print($content);
 	file_put_contents(LOG_PATH, $content, FILE_APPEND);
 }
 
@@ -128,10 +130,6 @@ function loadRepoConfigs($vendorDir,$repoNames){
 
 //解析部署配置文件
 function loadConfig($cfgPath){
-	if(! file_exists($cfgPath) ){
-		logError("config file not exists",$cfgPath);
-		return false;
-	}
 	$config = json_decode(file_get_contents($cfgPath), true);
 	if(!$config){
 		logError("failed to decode config file",$cfgPath);