Skip to content

Commit

Permalink
Added util method (reference #545)
Browse files Browse the repository at this point in the history
  • Loading branch information
rat-moonshine committed May 14, 2019
1 parent 0987222 commit effcc91
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
13 changes: 13 additions & 0 deletions InstallerSharedCore/src/actionScripts/utils/FileUtils.as
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,19 @@ package actionScripts.utils
return convertToFile(path);
}

/**
* Replace all the backslash to front-slashes
* in a given path value
*/
public static function normalizePath(path:String):String
{
if (path.indexOf("\\") != -1)
{
path = path.replace(/\\/g, "/");
}
return path;
}

private static function convertToFile(path:String):File
{
try
Expand Down
39 changes: 38 additions & 1 deletion InstallerSharedCore/src/actionScripts/utils/HelperUtils.as
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ package actionScripts.utils
// file-system check inside the named-sdk
if (validationPath && StringUtil.trim(validationPath).length != 0)
{
if (type == ComponentTypes.TYPE_OPENJAVA)
if (type == ComponentTypes.TYPE_OPENJAVA ||
type == ComponentTypes.TYPE_SVN ||
type == ComponentTypes.TYPE_GIT)
{
pathValidationFileName = HelperConstants.IS_MACOS ? validationPath : validationPath +".exe";
}
Expand All @@ -129,6 +131,41 @@ package actionScripts.utils
return false;
}

public static function isValidExecutableBy(type:String, originPath:String, validationPath:String=null):Boolean
{
var pathValidationFileName:String;
if (FileUtils.isPathExists(originPath))
{
// file-system check inside the named-sdk
if (validationPath && StringUtil.trim(validationPath).length != 0)
{
if (type == ComponentTypes.TYPE_OPENJAVA ||
type == ComponentTypes.TYPE_SVN ||
type == ComponentTypes.TYPE_GIT)
{
pathValidationFileName = HelperConstants.IS_MACOS ? validationPath : validationPath +".exe";
}
else
{
pathValidationFileName = validationPath;
}

originPath = FileUtils.normalizePath(originPath);
pathValidationFileName = FileUtils.normalizePath(pathValidationFileName);
if (originPath.indexOf(pathValidationFileName) != -1)
{
return true;
}
}
else
{
return true;
}
}

return false;
}

public static function updatePathWithCustomWindows(path:String):void
{
// probable termination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@
<title>Subversion</title>
<description><![CDATA[]]></description>
<image>/helperResources/images/logoSVN.png</image>
<pathValidation>bin\svn.exe</pathValidation>
<pathValidation>bin/svn</pathValidation>
<sdkType>svn</sdkType> <!-- flex, flexjs, royale, ant, openjava, maven, feathers -->
<website>https://feathersui.com</website>
<diskMBusage>
Expand Down Expand Up @@ -318,7 +318,7 @@
<title>Git</title>
<description><![CDATA[]]></description>
<image>/helperResources/images/logoGit.png</image>
<pathValidation>bin\git.exe</pathValidation>
<pathValidation>bin/git</pathValidation>
<sdkType>git</sdkType> <!-- flex, flexjs, royale, ant, openjava, maven, feathers -->
<website>https://feathersui.com</website>
<diskMBusage>
Expand Down

0 comments on commit effcc91

Please sign in to comment.