Skip to content

fixed global tool path detection #753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: dotnet-script build/Build.csx

build-mac:
runs-on: macos-latest
runs-on: macos-13
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this forces us back into intel Macs for now


steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,4 @@ project.json
/dotnet-script
/.vscode
/src/Dotnet.Script/Properties/launchSettings.json
.DS_Store
2 changes: 1 addition & 1 deletion src/Dotnet.Script.Core/Scaffolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private void CreateLaunchConfiguration(string currentWorkingDirectory)
_scriptConsole.WriteNormal("Creating VS Code launch configuration file");
string pathToLaunchFile = Path.Combine(vsCodeDirectory, "launch.json");
string installLocation = _scriptEnvironment.InstallLocation;
bool isInstalledAsGlobalTool = installLocation.Contains(".dotnet/tools", StringComparison.OrdinalIgnoreCase);
bool isInstalledAsGlobalTool = installLocation.Contains($".dotnet{Path.DirectorySeparatorChar}tools", StringComparison.OrdinalIgnoreCase);
string dotnetScriptPath = Path.Combine(installLocation, "dotnet-script.dll").Replace(@"\", "/");
string launchFileContent;
if (!File.Exists(pathToLaunchFile))
Expand Down
4 changes: 2 additions & 2 deletions src/Dotnet.Script.Tests/ScaffoldingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void ShouldUpdatePathToDotnetScript()
[Fact]
public void ShouldCreateUnifiedLaunchFileWhenInstalledAsGlobalTool()
{
Scaffolder scaffolder = CreateTestScaffolder("somefolder/.dotnet/tools/dotnet-script");
Scaffolder scaffolder = CreateTestScaffolder($"somefolder{Path.DirectorySeparatorChar}.dotnet{Path.DirectorySeparatorChar}tools{Path.DirectorySeparatorChar}dotnet-script");

using var scriptFolder = new DisposableFolder();
scaffolder.InitializerFolder("main.csx", scriptFolder.Path);
Expand All @@ -191,7 +191,7 @@ public void ShouldCreateUnifiedLaunchFileWhenInstalledAsGlobalTool()
public void ShouldUpdateToUnifiedLaunchFileWhenInstalledAsGlobalTool()
{
Scaffolder scaffolder = CreateTestScaffolder("some-install-folder");
Scaffolder globalToolScaffolder = CreateTestScaffolder("somefolder/.dotnet/tools/dotnet-script");
Scaffolder globalToolScaffolder = CreateTestScaffolder($"somefolder{Path.DirectorySeparatorChar}.dotnet{Path.DirectorySeparatorChar}tools{Path.DirectorySeparatorChar}dotnet-script");
using var scriptFolder = new DisposableFolder();
scaffolder.InitializerFolder("main.csx", scriptFolder.Path);
var fileContent = File.ReadAllText(Path.Combine(scriptFolder.Path, ".vscode", "launch.json"));
Expand Down
12 changes: 3 additions & 9 deletions src/Dotnet.Script.Tests/ScriptExecutionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ public void ShouldSupportInlineNugetReferencesWithTrailingSemicoloninEvaluatedCo

[Theory]
[InlineData("https://gist.githubusercontent.com/seesharper/5d6859509ea8364a1fdf66bbf5b7923d/raw/0a32bac2c3ea807f9379a38e251d93e39c8131cb/HelloWorld.csx",
"Hello World")]
"Hello World")]
[InlineData("http://gist.githubusercontent.com/seesharper/5d6859509ea8364a1fdf66bbf5b7923d/raw/0a32bac2c3ea807f9379a38e251d93e39c8131cb/HelloWorld.csx",
"Hello World")]
[InlineData("https://github.com/dotnet-script/dotnet-script/files/5035247/hello.csx.gz",
"Hello, world!")]
public void ShouldExecuteRemoteScript(string url, string output)
Expand All @@ -259,14 +261,6 @@ public void ShouldExecuteRemoteScript(string url, string output)
Assert.Contains(output, result.Output);
}

[Fact]
public void ShouldExecuteRemoteScriptUsingTinyUrl()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tinyurl implemented captcha using cloudflare and we can't use it anymore 😅

however I am not sure why this test even exists, I assume to test if would follow redirects? if that is the case, then I added an http:// variant to the test above, since github returns 301 then

{
var url = "https://tinyurl.com/y8cda9zt";
var (output, _) = ScriptTestRunner.Default.Execute(url);
Assert.Contains("Hello World", output);
}

[Fact]
public void ShouldHandleIssue268()
{
Expand Down
Loading