コード例 #1
0
 public void CreateFile(Stream stream, string remotePath)
 {
     Commands.Runner.Upload(stream, CrossPath.ToSsh(remotePath));
 }
コード例 #2
0
        public string LocateToolPath(string toolPath, string tool, string versionOption)
        {
            string foundPath = null;

            if (!string.IsNullOrEmpty(toolPath))
            {
                // if it was explicitly set, bail if it wasn't found
                toolPath = CrossPath.ToSsh(toolPath);
                if (Commands.FileExists(toolPath))
                {
                    foundPath = toolPath;
                }
            }
            else
            {
                // not set, so search
                var findTool = GetCommandResult($"which {tool}");
                if (!string.IsNullOrEmpty(findTool))
                {
                    foundPath = findTool.Trim();
                }
                else
                {
                    // we didn't find {tool} in the default places, so do a bit of research
                    var dirs    = string.Join(" ", ToolSearchPaths);
                    var command =
                        $@"for file in {dirs}; do " +
                        $@"  if [ -e ""$file/{tool}"" ]; then" +
                        $@"    echo ""$file/{tool}""; " +
                        $@"    exit 0; " +
                        $@"  fi; " +
                        $@"done; " +
                        $@"exit 1; ";
                    findTool = GetCommandResult(command);
                    if (!string.IsNullOrEmpty(findTool))
                    {
                        foundPath = findTool.Trim();
                    }
                }
            }

            if (string.IsNullOrEmpty(foundPath))
            {
                Log.LogError($"Unable to find {tool}.");
            }
            else
            {
                foundPath = CrossPath.ToSsh(foundPath);
                if (string.IsNullOrEmpty(versionOption))
                {
                    Log.LogVerbose($"Found {tool} at {foundPath}.");
                }
                else
                {
                    var version = GetCommandResult($"{foundPath} {versionOption}");
                    Log.LogVerbose($"Found {tool} version {version} at {foundPath}.");
                }
            }

            return(foundPath);
        }
コード例 #3
0
 public void CreateDirectory(string directoryPath)
 {
     Commands.CreateDirectory(CrossPath.ToSsh(directoryPath));
 }
コード例 #4
0
 public bool FileExists(string filePath)
 {
     return(Commands.FileExists(CrossPath.ToSsh(filePath)));
 }
コード例 #5
0
 public void CopyPath(string source, string destination)
 {
     ExecuteCommand($@"cp -rf ""{CrossPath.ToSsh(source)}"" ""{CrossPath.ToSsh(destination)}""");
 }