File tree Expand file tree Collapse file tree 2 files changed +58
-1
lines changed Expand file tree Collapse file tree 2 files changed +58
-1
lines changed Original file line number Diff line number Diff line change 1+ const esbuild = require ( "esbuild" ) ;
2+
3+ const production = process . argv . includes ( "--production" ) ;
4+ const watch = process . argv . includes ( "--watch" ) ;
5+
6+ async function main ( ) {
7+ const ctx = await esbuild . context ( {
8+ entryPoints : [ "src/test/runTest.ts" ] ,
9+ bundle : true ,
10+ format : "cjs" ,
11+ minify : production ,
12+ sourcemap : ! production ,
13+ sourcesContent : false ,
14+ platform : "node" ,
15+ outfile : "out/test/runTest.js" ,
16+ external : [ "vscode" , "jsonc-parser" ] ,
17+ logLevel : "silent" ,
18+ plugins : [
19+ /* add to the end of plugins array */
20+ esbuildProblemMatcherPlugin ,
21+ ] ,
22+ } ) ;
23+ if ( watch ) {
24+ await ctx . watch ( ) ;
25+ } else {
26+ await ctx . rebuild ( ) ;
27+ await ctx . dispose ( ) ;
28+ }
29+ }
30+
31+ /**
32+ * @type {import('esbuild').Plugin }
33+ */
34+ const esbuildProblemMatcherPlugin = {
35+ name : "esbuild-problem-matcher" ,
36+
37+ setup ( build ) {
38+ build . onStart ( ( ) => {
39+ console . log ( "[watch] build started" ) ;
40+ } ) ;
41+ build . onEnd ( ( result ) => {
42+ result . errors . forEach ( ( { text, location } ) => {
43+ console . error ( `✘ [ERROR] ${ text } ` ) ;
44+ console . error (
45+ ` ${ location . file } :${ location . line } :${ location . column } :` ,
46+ ) ;
47+ } ) ;
48+ console . log ( "[watch] build finished" ) ;
49+ } ) ;
50+ } ,
51+ } ;
52+
53+ main ( ) . catch ( ( e ) => {
54+ console . error ( e ) ;
55+ process . exit ( 1 ) ;
56+ } ) ;
Original file line number Diff line number Diff line change 3131 "_vscode:pack" : " rm snippetsmanager-*.vsix; vsce package --yarn" ,
3232 "_vscode:uninstall" : " code --uninstall-extension zjffun.snippetsmanager" ,
3333 "compile" : " yarn run editor-view:build && node esbuild.js" ,
34+ "compile-test" : " node esbuild-test.js" ,
3435 "compile-web" : " webpack --mode production --devtool hidden-source-map" ,
3536 "editor-view:build" : " webpack --config ./views/code-snippets-editor/webpack.config.js --mode=production --node-env=production" ,
3637 "editor-view:build:dev" : " webpack --config ./views/code-snippets-editor/webpack.config.js --mode=development" ,
3738 "editor-view:watch" : " webpack --config ./views/code-snippets-editor/webpack.config.js --watch" ,
3839 "eslint-fix" : " eslint --fix ." ,
3940 "prettier-fix" : " prettier --write ." ,
40- "test" : " node ./out/test/runTest.js" ,
41+ "test" : " yarn run compile-test && node ./out/test/runTest.js" ,
4142 "test-web" : " vscode-test-web --extensionDevelopmentPath=. --extensionTestsPath=./dist/web/test/suite/index.js ./test.temp" ,
4243 "watch" : " concurrently \" yarn run editor-view:watch\" \" node esbuild.js --watch\" " ,
4344 "watch-web" : " webpack --watch" ,
You can’t perform that action at this time.
0 commit comments