Esempio n. 1
0
        public static NodeHost CreateFromScript(string handlerScript, string projectPath, ILogger logger)
        {
            var handlerFile = new StringAsTempFile(handlerScript);
            var result      = NodeHost.Create(handlerFile.FileName, projectPath, logger);

            result._handlerFile = handlerFile;
            return(result);
        }
Esempio n. 2
0
        public static NodeHost CreateFromScript(string handlerScript, string projectPath, CancellationToken applicationStopping, ILogger logger, IDictionary <string, string> environmentVars)
        {
            var handlerFile = new StringAsTempFile(handlerScript, applicationStopping);
            var result      = NodeHost.Create(handlerFile.FileName, projectPath, applicationStopping, logger, environmentVars);

            result._handlerFile = handlerFile;
            return(result);
        }
        public static async Task <NodeHost> Create(string handlerFile, string projectPath, CancellationToken applicationStopping, ILogger logger, IDictionary <string, string> environmentVars)
        {
            var hostScript = EmbeddedResourceReader.Read(typeof(NodeHost), "/Content/node-host.js");
            var result     = new NodeHost(hostScript, projectPath, "\"" + handlerFile + "\"", applicationStopping, logger, environmentVars);
            await result.Start();

            return(result);
        }
        private async Task <NodeHost> CreateHost(string basePath)
        {
            var host = NodeHost.Create("webpack-aspnet-middleware", basePath, _logger);

            host.Emit += WebpackEmit;
            await host.Invoke("start", Path.Combine(basePath, _options.ConfigFile), _options.LogLevel);

            return(host);
        }
Esempio n. 5
0
        private async Task <NodeHost> CreateHost(IHostingEnvironment environment, IApplicationLifetime lifetime)
        {
            var environmentVariables = new Dictionary <string, string>();

            environmentVariables["NODE_ENV"] = environment.IsDevelopment() ? "development" : "production";

            var host = NodeHost.Create("webpack-aspnet-middleware", environment.ContentRootPath, lifetime.ApplicationStopping, _logger, environmentVariables);

            host.Emit += WebpackEmit;
            await host.Invoke("start", Path.Combine(environment.ContentRootPath, _options.ConfigFile), _options.LogLevel);

            return(host);
        }
Esempio n. 6
0
        public async Task Start(CancellationToken stoppingToken)
        {
            var environmentVariables = new Dictionary <string, string>();

            environmentVariables["NODE_ENV"] = _environment.EnvironmentName.ToLower();

            var startParams = new {
                LogLevel = _options.LogLevel,
                EnvParam = _options.EnvParam ?? _environment.EnvironmentName.ToLower()
            };

            _host = await NodeHost.Create("webpack-aspnet-middleware", _environment.ContentRootPath, stoppingToken, _logger, environmentVariables);

            _host.Emit += WebpackEmit;

            await _host.Invoke("start", Path.Combine(_environment.ContentRootPath, _options.ConfigFile), startParams.LogLevel);
        }