Changed file watching development setup.

No longer launches browser.

Added watch server task for API work.

watch_all.py only displays server output and client error output.
This commit is contained in:
Harrison Deng 2021-07-11 02:38:18 -05:00
parent 80978c652a
commit c1633b0b51
3 changed files with 26 additions and 12 deletions

View File

@ -2,7 +2,7 @@
"version": "2.0.0", "version": "2.0.0",
"tasks": [ "tasks": [
{ {
"label": "build", "label": "build app",
"command": "dotnet", "command": "dotnet",
"type": "process", "type": "process",
"args": [ "args": [
@ -14,7 +14,7 @@
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "publish", "label": "publish app",
"command": "dotnet", "command": "dotnet",
"type": "process", "type": "process",
"args": [ "args": [
@ -30,9 +30,21 @@
"command": "py", "command": "py",
"type": "process", "type": "process",
"args": [ "args": [
"scripts/watch_all.py" "${workspaceFolder}/scripts/watch_all.py"
], ],
"problemMatcher": ["$msCompile", "$node-sass", "$jshint"], "problemMatcher": ["$msCompile", "$node-sass", "$jshint"],
}, },
{
"label": "watch server",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"-p",
"${workspaceFolder}/server/MultiShop.csproj",
"run"
],
"problemMatcher": ["$msCompile"]
}
] ]
} }

View File

@ -1,29 +1,31 @@
import os import os
import asyncio import asyncio
import sys
SERVER_CSPROJ_DIR = "server" SERVER_CSPROJ_DIR = "server"
CLIENT_PACKAGE_DIR = "client" CLIENT_PACKAGE_DIR = "client"
async def exec(cmd, path): async def exec(cmd, path, silent=False):
devnull = open(os.devnull, "wb")
os.chdir(os.path.dirname(os.path.realpath(__file__))) os.chdir(os.path.dirname(os.path.realpath(__file__)))
os.chdir(os.pardir) os.chdir(os.pardir)
os.chdir(path) os.chdir(path)
print("Executing \"{0}\" in \"{1}\".".format(cmd, path)) print("Executing \"{0}\" in \"{1}\".".format(cmd, path))
proc = await asyncio.create_subprocess_shell( proc = None
cmd, if (not silent):
stdout=sys.stdout, proc = await asyncio.create_subprocess_shell(cmd)
stderr=sys.stderr, else:
) print("Executing in silent mode.")
proc = await asyncio.create_subprocess_shell(cmd, stdout=devnull)
await proc.wait() await proc.wait()
devnull.close()
async def main(): async def main():
print("Beginning development servers.") print("Beginning development servers.")
await asyncio.gather( await asyncio.gather(
exec("dotnet watch run", SERVER_CSPROJ_DIR), exec("dotnet watch run", SERVER_CSPROJ_DIR),
exec("npm run serve", CLIENT_PACKAGE_DIR)) exec("npm run serve", CLIENT_PACKAGE_DIR, silent=True))
asyncio.run(main()) asyncio.run(main())

View File

@ -17,7 +17,7 @@
}, },
"MultiShop": { "MultiShop": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": false,
"applicationUrl": "http://localhost:5000;https://localhost:5001", "applicationUrl": "http://localhost:5000;https://localhost:5001",
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"