elviss 2 éve
szülő
commit
3bddea07c9
2 módosított fájl, 24 hozzáadás és 10 törlés
  1. 9 7
      src/PackageClass.php
  2. 15 3
      src/Utility.php

+ 9 - 7
src/PackageClass.php

@@ -150,15 +150,17 @@ class PackageClass
 		//获取部署配置信息
 		$cfgPath = pathJoin($distributeDir,'config.json');
 		if(! file_exists($cfgPath) ){
-			logError("distribute config file not exists",$cfgPath);
-			return false;
+			logInfo("distribute config file not exists,use default config.",$cfgPath);
+			self::$config = defaultConfig();
 		}
-		self::$config = loadConfig($cfgPath);
-		if(!self::$config){
-			logError("Failed to load distribute config",$cfgPath);
-			return false;
+		else{
+			self::$config = loadConfig($cfgPath);
+			if(!self::$config){
+				logError("Failed to load distribute config",$cfgPath);
+				return false;
+			}
+			logInfo("succeeded to decode config file -- .distribute/config.json");
 		}
-		logInfo("succeeded to decode config file -- .distribute/config.json");
 		return true;
 	}
 	

+ 15 - 3
src/Utility.php

@@ -51,12 +51,16 @@ function isZipFile($fileName){
 }
 //获取 gopeed.exe 路径
 function getGoPeedPath($toolDir){
-	return pathJoin($toolDir,"gopeed.exe");
+	if(!$toolDir)
+		return 'gopeed.exe';
+	return pathJoin($toolDir,'gopeed.exe');
 }
 
 //获取 7z.exe 路径
 function get7ZipPath($toolDir){
-	return pathJoin($toolDir,"7z.exe");
+	if(!$toolDir)
+		return '7z.exe';
+	return pathJoin($toolDir,'7z.exe');
 }
 //两个参数的路径拼接
 function twoPathJoin($base, $path) {
@@ -148,7 +152,15 @@ function loadRepoConfigs($vendorDir,$repoNames){
 	}
 	return $configs;
 }
-
+//默认配置信息
+function defaultConfig($cfgPath){
+	return array(
+		'distribute-mode' => 'install',
+		'cache-dir' => 'd:/dist-cache/',
+		'tool-dir' => '',
+		'oss-host' => 'http://distribute-helper.oss-cn-hangzhou.aliyuncs.com',
+	);
+}
 //解析部署配置文件
 function loadConfig($cfgPath){
 	$config = json_decode(file_get_contents($cfgPath), true);