/// <summary> /// Initializes a new instance of the <see cref="MutableCakeEnvironment" /> class. /// </summary> /// <param name="platform">The platform.</param> /// <param name="runtime">The runtime.</param> /// <param name="appRoot">App root path</param> public MutableCakeEnvironment(ICakePlatform platform, ICakeRuntime runtime, string appRoot = null) { _platform = platform; _runtime = runtime; var rootPath = string.IsNullOrEmpty(appRoot) ? Assembly.GetExecutingAssembly().Location : appRoot; _applicationRoot = System.IO.Path.GetDirectoryName(rootPath); WorkingDirectory = new DirectoryPath(Environment.CurrentDirectory); var pathEnv = Environment.GetEnvironmentVariable("PATH"); if (!string.IsNullOrEmpty(pathEnv)) { _paths = pathEnv.Split(new char[] { _platform.IsUnix() ? ':' : ';' }, StringSplitOptions.RemoveEmptyEntries) .Select(s => s.Trim()) .Where(s => s.Length > 0) .ToList(); } else { _paths = new List <string>(); } _addedPaths = new List <string>(); _dynamicPaths = new List <string>(); }
private static string GetXPlatFolderPath(ICakePlatform platform, SpecialPath path) { if (platform.IsUnix()) { return(Native.Unix.GetFolder(path)); } else if (platform.Family == PlatformFamily.Windows) { return(Native.Windows.GetFolder(path)); } throw new PlatformNotSupportedException(); }
/// <summary> /// Initializes a new instance of the <see cref="MutableCakeEnvironment" /> class. /// </summary> /// <param name="platform">The platform.</param> /// <param name="runtime">The runtime.</param> public MutableCakeEnvironment( ICakePlatform platform, ICakeRuntime runtime ) { _platform = platform; _runtime = runtime; _applicationRoot = System.IO.Path.GetDirectoryName( Assembly.GetExecutingAssembly().Location ); WorkingDirectory = new DirectoryPath( Environment.CurrentDirectory ); var pathEnv = Environment.GetEnvironmentVariable( "PATH" ); if( !string.IsNullOrEmpty( pathEnv ) ) { _paths = pathEnv.Split( new char[] { _platform.IsUnix() ? ':' : ';' }, StringSplitOptions.RemoveEmptyEntries ) .Select( s => s.Trim() ) .Where( s => s.Length > 0 ) .ToList(); } else { _paths = new List<string>(); } _addedPaths = new List<string>(); _dynamicPaths = new List<string>(); }
public bool IsUnix() { return(_platform.IsUnix()); }
protected override IEnumerable <string> GetToolExecutableNames() { return(new[] { _platform.IsUnix() ? "pulumi" : "pulumi.exe" }); }
public bool IsUnix() => _platform.IsUnix();
/// <summary> /// Gets the name of the tool executable /// </summary> /// <returns>The tool executable name</returns> protected override IEnumerable <string> GetToolExecutableNames() { yield return(_platform.IsUnix() ? "yarn" : "yarn.cmd"); }