public void CreateFile(Stream stream, string remotePath) { Commands.Runner.Upload(stream, CrossPath.ToSsh(remotePath)); }
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); }
public void CreateDirectory(string directoryPath) { Commands.CreateDirectory(CrossPath.ToSsh(directoryPath)); }
public bool FileExists(string filePath) { return(Commands.FileExists(CrossPath.ToSsh(filePath))); }
public void CopyPath(string source, string destination) { ExecuteCommand($@"cp -rf ""{CrossPath.ToSsh(source)}"" ""{CrossPath.ToSsh(destination)}"""); }