1- import childProcess from "child_process" ;
21import fs from "fs-extra" ;
32import path from "path" ;
43import glob from "glob" ;
54import url from "url" ;
5+ import del from "del" ;
66
77const __filename = url . fileURLToPath ( new URL ( import . meta. url ) ) ;
88const __dirname = path . dirname ( __filename ) ;
@@ -14,12 +14,13 @@ const copyright = fs.readFileSync(path.join(__dirname, "../CopyrightNotice.txt")
1414
1515async function produceLKG ( ) {
1616 console . log ( `Building LKG from ${ source } to ${ dest } ` ) ;
17+ await del ( `${ dest . replace ( / \\ / g, "/" ) } /**` , { ignore : [ "**/README.md" ] } ) ;
18+ await fs . mkdirp ( dest ) ;
1719 await copyLibFiles ( ) ;
1820 await copyLocalizedDiagnostics ( ) ;
1921 await copyTypesMap ( ) ;
2022 await copyScriptOutputs ( ) ;
2123 await copyDeclarationOutputs ( ) ;
22- await buildProtocol ( ) ;
2324 await writeGitAttributes ( ) ;
2425}
2526
@@ -46,20 +47,6 @@ async function copyTypesMap() {
4647 await copyFromBuiltLocal ( "typesMap.json" ) ; // Cannot accommodate copyright header
4748}
4849
49- async function buildProtocol ( ) {
50- const protocolScript = path . join ( __dirname , "buildProtocol.mjs" ) ;
51- if ( ! fs . existsSync ( protocolScript ) ) {
52- throw new Error ( `Expected protocol script ${ protocolScript } to exist` ) ;
53- }
54-
55- const protocolInput = path . join ( __dirname , "../src/server/protocol.ts" ) ;
56- const protocolServices = path . join ( source , "typescriptServices.d.ts" ) ;
57- const protocolOutput = path . join ( dest , "protocol.d.ts" ) ;
58-
59- console . log ( `Building ${ protocolOutput } ...` ) ;
60- await exec ( protocolScript , [ protocolInput , protocolServices , protocolOutput ] ) ;
61- }
62-
6350async function copyScriptOutputs ( ) {
6451 await copyWithCopyright ( "cancellationToken.js" ) ;
6552 await copyWithCopyright ( "tsc.release.js" , "tsc.js" ) ;
@@ -109,16 +96,6 @@ async function copyFilesWithGlob(pattern) {
10996 console . log ( `Copied ${ files . length } files matching pattern ${ pattern } ` ) ;
11097}
11198
112- /**
113- * @param {string } path
114- * @param {string[] } args
115- */
116- async function exec ( path , args = [ ] ) {
117- const cmdLine = [ "node" , path , ...args ] . join ( " " ) ;
118- console . log ( cmdLine ) ;
119- childProcess . execSync ( cmdLine ) ;
120- }
121-
12299process . on ( "unhandledRejection" , err => {
123100 throw err ;
124101} ) ;
0 commit comments