From 5474b57d8d52fb1675120837746d7cc1c2b3c00a Mon Sep 17 00:00:00 2001 From: Wesley Ford Date: Sat, 18 Nov 2023 19:24:02 -0600 Subject: [PATCH] Update aspnetcore-https.js --- src/EducationTrail/ClientApp/aspnetcore-https.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/EducationTrail/ClientApp/aspnetcore-https.js b/src/EducationTrail/ClientApp/aspnetcore-https.js index 1286f1c..9e58786 100644 --- a/src/EducationTrail/ClientApp/aspnetcore-https.js +++ b/src/EducationTrail/ClientApp/aspnetcore-https.js @@ -1,14 +1,14 @@ +// This script sets up HTTPS for the application using the ASP.NET Core HTTPS certificate const fs = require('fs'); const spawn = require('child_process').spawn; + const path = require('path'); -// Determine the base folder based on the environment const baseFolder = process.env.APPDATA !== undefined && process.env.APPDATA !== '' ? `${process.env.APPDATA}/ASP.NET/https` : `${process.env.HOME}/.aspnet/https`; -// Determine the certificate name based on the environment or provided argument const certificateArg = process.argv.map(arg => arg.match(/--name=(?.+)/i)).filter(Boolean)[0]; const certificateName = certificateArg ? certificateArg.groups.value : process.env.npm_package_name; @@ -17,11 +17,9 @@ if (!certificateName) { process.exit(-1); } -// Adjust paths based on the environment const certFilePath = path.join(baseFolder, `${certificateName}.pem`); const keyFilePath = path.join(baseFolder, `${certificateName}.key`); -// Check if certificates exist, and generate if not if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) { spawn('dotnet', [ 'dev-certs', @@ -38,4 +36,4 @@ if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) { module.exports = { certFilePath, keyFilePath -}; \ No newline at end of file +} \ No newline at end of file