@@ -9,16 +9,17 @@ const __filename = fileURLToPath(import.meta.url)
99const __dirname = path . dirname ( __filename )
1010
1111async function main ( ) {
12+ const name = "extension-nightly"
1213 const production = process . argv . includes ( "--production" )
1314 const minify = production
1415 const sourcemap = ! production
1516
1617 const overrideJson = JSON . parse ( fs . readFileSync ( path . join ( __dirname , "package.nightly.json" ) , "utf8" ) )
17- console . log ( `[main ] name: ${ overrideJson . name } ` )
18- console . log ( `[main ] version: ${ overrideJson . version } ` )
18+ console . log ( `[${ name } ] name: ${ overrideJson . name } ` )
19+ console . log ( `[${ name } ] version: ${ overrideJson . version } ` )
1920
2021 const gitSha = getGitSha ( )
21- console . log ( `[main ] gitSha: ${ gitSha } ` )
22+ console . log ( `[${ name } ] gitSha: ${ gitSha } ` )
2223
2324 /**
2425 * @type {import('esbuild').BuildOptions }
@@ -43,12 +44,22 @@ async function main() {
4344 const buildDir = path . join ( __dirname , "build" )
4445 const distDir = path . join ( buildDir , "dist" )
4546
47+ console . log ( `[${ name } ] srcDir: ${ srcDir } ` )
48+ console . log ( `[${ name } ] buildDir: ${ buildDir } ` )
49+ console . log ( `[${ name } ] distDir: ${ distDir } ` )
50+
51+ // Clean build directory before starting new build
52+ if ( fs . existsSync ( buildDir ) ) {
53+ console . log ( `[${ name } ] Cleaning build directory: ${ buildDir } ` )
54+ fs . rmSync ( buildDir , { recursive : true , force : true } )
55+ }
56+
4657 /**
4758 * @type {import('esbuild').Plugin[] }
4859 */
4960 const plugins = [
5061 {
51- name : "copy-files " ,
62+ name : "copyPaths " ,
5263 setup ( build ) {
5364 build . onEnd ( ( ) => {
5465 copyPaths (
@@ -69,7 +80,7 @@ async function main() {
6980 } ,
7081 } ,
7182 {
72- name : "generate-package-json " ,
83+ name : "generatePackageJson " ,
7384 setup ( build ) {
7485 build . onEnd ( ( ) => {
7586 const packageJson = JSON . parse ( fs . readFileSync ( path . join ( srcDir , "package.json" ) , "utf8" ) )
@@ -81,7 +92,7 @@ async function main() {
8192 } )
8293
8394 fs . writeFileSync ( path . join ( buildDir , "package.json" ) , JSON . stringify ( generatedPackageJson , null , 2 ) )
84- console . log ( `[generate-package-json ] Generated package.json` )
95+ console . log ( `[generatePackageJson ] Generated package.json` )
8596
8697 let count = 0
8798
@@ -92,7 +103,7 @@ async function main() {
92103 }
93104 } )
94105
95- console . log ( `[copy-src ] Copied ${ count } package.nls*.json files to ${ buildDir } ` )
106+ console . log ( `[generatePackageJson ] Copied ${ count } package.nls*.json files to ${ buildDir } ` )
96107
97108 const nlsPkg = JSON . parse ( fs . readFileSync ( path . join ( srcDir , "package.nls.json" ) , "utf8" ) )
98109
@@ -105,18 +116,18 @@ async function main() {
105116 JSON . stringify ( { ...nlsPkg , ...nlsNightlyPkg } , null , 2 ) ,
106117 )
107118
108- console . log ( `[copy-src ] Generated package.nls.json` )
119+ console . log ( `[generatePackageJson ] Generated package.nls.json` )
109120 } )
110121 } ,
111122 } ,
112123 {
113- name : "copy-wasms " ,
124+ name : "copyWasms " ,
114125 setup ( build ) {
115126 build . onEnd ( ( ) => copyWasms ( srcDir , distDir ) )
116127 } ,
117128 } ,
118129 {
119- name : "copy-locales " ,
130+ name : "copyLocales " ,
120131 setup ( build ) {
121132 build . onEnd ( ( ) => copyLocales ( srcDir , distDir ) )
122133 } ,
0 commit comments