1- import fs from "fs-extra " ;
1+ import fs from "fs" ;
22import glob from "glob" ;
33import path from "path" ;
44import url from "url" ;
@@ -16,8 +16,8 @@ const dest = path.join(root, "lib");
1616
1717async function produceLKG ( ) {
1818 console . log ( `Building LKG from ${ source } to ${ dest } ` ) ;
19- await ( fs . rm || fs . rmdir ) ( dest , { recursive : true , force : true } ) ;
20- await fs . mkdirp ( dest ) ;
19+ await fs . promises . rm ( dest , { recursive : true , force : true } ) ;
20+ await fs . promises . mkdir ( dest , { recursive : true } ) ;
2121 await copyLibFiles ( ) ;
2222 await copyLocalizedDiagnostics ( ) ;
2323 await copyTypesMap ( ) ;
@@ -32,9 +32,15 @@ async function copyLibFiles() {
3232
3333async function copyLocalizedDiagnostics ( ) {
3434 for ( const d of localizationDirectories ) {
35- const fileName = path . join ( source , d ) ;
36- if ( fs . statSync ( fileName ) . isDirectory ( ) ) {
37- await fs . copy ( fileName , path . join ( dest , d ) ) ;
35+ const inputDir = path . join ( source , d ) ;
36+ if ( ! fs . statSync ( inputDir ) . isDirectory ( ) ) throw new Error ( `Expected ${ inputDir } to be a directory` ) ;
37+ const outputDir = path . join ( dest , d ) ;
38+ await fs . promises . mkdir ( outputDir , { recursive : true } ) ;
39+ for ( const f of await fs . promises . readdir ( inputDir ) ) {
40+ const inputFile = path . join ( inputDir , f ) ;
41+ if ( ! fs . statSync ( inputFile ) . isFile ( ) ) throw new Error ( `Expected ${ inputFile } to be a file` ) ;
42+ const outputFile = path . join ( outputDir , f ) ;
43+ await fs . promises . copyFile ( inputFile , outputFile ) ;
3844 }
3945 }
4046}
@@ -59,14 +65,14 @@ async function copyDeclarationOutputs() {
5965}
6066
6167async function writeGitAttributes ( ) {
62- await fs . writeFile ( path . join ( dest , ".gitattributes" ) , `* text eol=lf` , "utf-8" ) ;
68+ await fs . promises . writeFile ( path . join ( dest , ".gitattributes" ) , `* text eol=lf` , "utf-8" ) ;
6369}
6470
6571/**
6672 * @param {string } fileName
6773 */
6874async function copyFromBuiltLocal ( fileName ) {
69- await fs . copy ( path . join ( source , fileName ) , path . join ( dest , fileName ) ) ;
75+ await fs . promises . copyFile ( path . join ( source , fileName ) , path . join ( dest , fileName ) ) ;
7076}
7177
7278/**
0 commit comments