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",
"tasks": [
{
"label": "build",
"label": "build app",
"command": "dotnet",
"type": "process",
"args": [
@ -14,7 +14,7 @@
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"label": "publish app",
"command": "dotnet",
"type": "process",
"args": [
@ -30,9 +30,21 @@
"command": "py",
"type": "process",
"args": [
"scripts/watch_all.py"
"${workspaceFolder}/scripts/watch_all.py"
],
"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 asyncio
import sys
SERVER_CSPROJ_DIR = "server"
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.pardir)
os.chdir(path)
print("Executing \"{0}\" in \"{1}\".".format(cmd, path))
proc = await asyncio.create_subprocess_shell(
cmd,
stdout=sys.stdout,
stderr=sys.stderr,
)
proc = None
if (not silent):
proc = await asyncio.create_subprocess_shell(cmd)
else:
print("Executing in silent mode.")
proc = await asyncio.create_subprocess_shell(cmd, stdout=devnull)
await proc.wait()
devnull.close()
async def main():
print("Beginning development servers.")
await asyncio.gather(
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())

View File

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