mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Add ability to configure environment variables for Node instances, plus auto-populate NODE_ENV based on IHostingEnvironment when possible. Fixes #230
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNetCore.NodeServices.HostingModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
@@ -22,6 +23,23 @@ namespace Microsoft.AspNetCore.NodeServices
|
||||
public string[] WatchFileExtensions { get; set; }
|
||||
public ILogger NodeInstanceOutputLogger { get; set; }
|
||||
public bool LaunchWithDebugging { get; set; }
|
||||
public IDictionary<string, string> EnvironmentVariables { get; set; }
|
||||
public int? DebuggingPort { get; set; }
|
||||
|
||||
public NodeServicesOptions AddDefaultEnvironmentVariables(bool isDevelopmentMode)
|
||||
{
|
||||
if (EnvironmentVariables == null)
|
||||
{
|
||||
EnvironmentVariables = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
if (!EnvironmentVariables.ContainsKey("NODE_ENV"))
|
||||
{
|
||||
// These strings are a de-facto standard in Node
|
||||
EnvironmentVariables["NODE_ENV"] = isDevelopmentMode ? "development" : "production";
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user