1- const fs = require ( "fs" ) ;
2- const path = require ( " path" ) ;
3- const crypto = require ( " crypto" ) ;
4- const { execSync } = require ( " child_process" ) ;
1+ const fs = require ( 'fs' ) ;
2+ const path = require ( ' path' ) ;
3+ const crypto = require ( ' crypto' ) ;
4+ const { execSync } = require ( ' child_process' ) ;
55
6- const ROOT = path . resolve ( __dirname , ".." ) ;
7- const DOCS = path . join ( ROOT , " docs" ) ;
8- const DIST = path . join ( ROOT , " dist" ) ;
9- const TMP = path . join ( ROOT , " dist.tmp" ) ;
10- const OLD = path . join ( ROOT , " dist.old" ) ;
6+ const ROOT = path . resolve ( __dirname , '..' ) ;
7+ const DOCS = path . join ( ROOT , ' docs' ) ;
8+ const DIST = path . join ( ROOT , ' dist' ) ;
9+ const TMP = path . join ( ROOT , ' dist.tmp' ) ;
10+ const OLD = path . join ( ROOT , ' dist.old' ) ;
1111
1212function sha256 ( buf ) {
13- return crypto . createHash ( " sha256" ) . update ( buf ) . digest ( " hex" ) ;
13+ return crypto . createHash ( ' sha256' ) . update ( buf ) . digest ( ' hex' ) ;
1414}
1515
1616function gitVersion ( ) {
1717 if ( process . env . GITHUB_SHA ) return process . env . GITHUB_SHA . slice ( 0 , 12 ) ;
1818 try {
19- return execSync ( "git rev-parse --short=12 HEAD" , { cwd : ROOT } )
20- . toString ( )
21- . trim ( ) ;
19+ return execSync ( 'git rev-parse --short=12 HEAD' , { cwd : ROOT } ) . toString ( ) . trim ( ) ;
2220 } catch {
23- return " unknown" ;
21+ return ' unknown' ;
2422 }
2523}
2624
@@ -45,7 +43,7 @@ function copyTree(srcDir, destDir) {
4543 const data = fs . readFileSync ( srcPath ) ;
4644 fs . writeFileSync ( destPath , data ) ;
4745 records . push ( {
48- path : rel . split ( path . sep ) . join ( "/" ) ,
46+ path : rel . split ( path . sep ) . join ( '/' ) ,
4947 size : data . length ,
5048 sha256 : sha256 ( data ) ,
5149 } ) ;
@@ -55,9 +53,7 @@ function copyTree(srcDir, destDir) {
5553
5654function buildTree ( dir ) {
5755 const tree = { } ;
58- const entries = fs
59- . readdirSync ( dir , { withFileTypes : true } )
60- . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ;
56+ const entries = fs . readdirSync ( dir , { withFileTypes : true } ) . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ;
6157 for ( const e of entries ) {
6258 if ( e . isDirectory ( ) ) {
6359 tree [ e . name ] = buildTree ( path . join ( dir , e . name ) ) ;
@@ -88,20 +84,14 @@ function main() {
8884 tree,
8985 } ;
9086
91- fs . writeFileSync (
92- path . join ( TMP , "manifest.json" ) ,
93- JSON . stringify ( manifest , null , 2 ) ,
94- "utf8"
95- ) ;
87+ fs . writeFileSync ( path . join ( TMP , 'manifest.json' ) , JSON . stringify ( manifest , null , 2 ) , 'utf8' ) ;
9688
9789 rmrf ( OLD ) ;
9890 if ( fs . existsSync ( DIST ) ) fs . renameSync ( DIST , OLD ) ;
9991 fs . renameSync ( TMP , DIST ) ;
10092 rmrf ( OLD ) ;
10193
102- console . log (
103- `built dist/ — ${ files . length } files, version ${ manifest . version } `
104- ) ;
94+ console . log ( `built dist/ — ${ files . length } files, version ${ manifest . version } ` ) ;
10595}
10696
10797main ( ) ;
0 commit comments