File tree Expand file tree Collapse file tree 3 files changed +60
-2
lines changed
Expand file tree Collapse file tree 3 files changed +60
-2
lines changed Original file line number Diff line number Diff line change 4444 "problemMatcher" : " $ts-webpack-watch" ,
4545 "options" : {
4646 "cwd" : " ${workspaceFolder}/../../packages/core"
47- }
47+ },
48+ "presentation" : { "panel" : " dedicated" }
4849 },
4950 {
5051 "label" : " terminate" ,
Original file line number Diff line number Diff line change 424424 "compileOnly" : " tsc -p ./" ,
425425 "compileDev" : " npm run compile -- --mode development" ,
426426 "webpackDev" : " webpack --mode development" ,
427- "serveVue" : " webpack serve --config-name vue --mode development" ,
427+ "serveVue" : " ts-node ./scripts/build/checkServerPort.ts && webpack serve --port 8080 --config-name vue --mode development" ,
428428 "watch" : " npm run clean && npm run buildScripts && npm run compileOnly -- --watch" ,
429429 "lint" : " ts-node ./scripts/lint/testLint.ts" ,
430430 "generateClients" : " ts-node ./scripts/build/generateServiceClient.ts " ,
Original file line number Diff line number Diff line change 1+ /*!
2+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+ * SPDX-License-Identifier: Apache-2.0
4+ */
5+
6+ /**
7+ * Validate that the required port used by webviews during development is not being used.
8+ */
9+
10+ import * as net from 'net'
11+
12+ /** This must be kept up to date with the port that is being used to serve the vue files. */
13+ const portNumber = 8080
14+
15+ function checkPort ( port : number ) : Promise < boolean > {
16+ return new Promise ( ( resolve ) => {
17+ const server = net . createServer ( )
18+
19+ server . once ( 'error' , ( err ) => {
20+ if ( ( err as NodeJS . ErrnoException ) . code === 'EADDRINUSE' ) {
21+ resolve ( true )
22+ }
23+ } )
24+
25+ server . once ( 'listening' , ( ) => {
26+ server . close ( )
27+ resolve ( false )
28+ } )
29+
30+ server . listen ( port )
31+ } )
32+ }
33+
34+ async function main ( ) {
35+ try {
36+ const isPortInUse = await checkPort ( portNumber )
37+
38+ if ( isPortInUse ) {
39+ console . error ( `
40+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
41+
42+ ERROR: Webviews will not load as expected, meaning Q may not work.
43+ REASON: Port ${ portNumber } is already in use, preventing the latest webview files from being served.
44+ SOLUTION: Kill the current process using port ${ portNumber } .
45+ - Unix: "kill -9 $(lsof -t -i :${ portNumber } )"
46+
47+ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
48+ ` )
49+ process . exit ( 1 )
50+ }
51+ } catch ( error ) {
52+ console . error ( 'Error checking port:' , error )
53+ process . exit ( 1 )
54+ }
55+ }
56+
57+ void main ( )
You can’t perform that action at this time.
0 commit comments