-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from max-ieremenko/release/2.1.3
Release/2.1.3
- Loading branch information
Showing
24 changed files
with
196 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System; | ||
using System.IO; | ||
using System.Management.Automation; | ||
using SqlDatabase.Configuration; | ||
|
||
namespace SqlDatabase.PowerShell | ||
{ | ||
internal static class CmdletExtensions | ||
{ | ||
public static string GetWorkingDirectory(this PSCmdlet cmdlet) | ||
{ | ||
var root = cmdlet.MyInvocation.PSScriptRoot; | ||
if (string.IsNullOrEmpty(root)) | ||
{ | ||
root = cmdlet.CurrentProviderLocation("FileSystem").ProviderPath; | ||
} | ||
|
||
return root; | ||
} | ||
|
||
public static string RootPath(this PSCmdlet cmdlet, string path) | ||
{ | ||
if (string.IsNullOrEmpty(path) || Path.IsPathRooted(path)) | ||
{ | ||
return path; | ||
} | ||
|
||
return Path.Combine(GetWorkingDirectory(cmdlet), path); | ||
} | ||
|
||
public static bool TryGetPSVersionTable(this PSCmdlet cmdlet, out PSVersionTable value) | ||
{ | ||
var psVersionTable = cmdlet.GetVariableValue("PSVersionTable"); | ||
if (psVersionTable == null) | ||
{ | ||
value = default; | ||
return false; | ||
} | ||
|
||
value = new PSVersionTable(psVersionTable); | ||
return true; | ||
} | ||
|
||
public static void AppendFrom(this PSCmdlet cmdlet, string[] from, GenericCommandLineBuilder target) | ||
{ | ||
if (from != null) | ||
{ | ||
for (var i = 0; i < from.Length; i++) | ||
{ | ||
target.SetScripts(cmdlet.RootPath(from[i])); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.