11'use strict' ;
22
3- const fs = require ( 'fs' ) ;
4- const extra = require ( 'fs-extra' ) ;
3+ const fs = require ( '@npmcli/fs' )
54const util = require ( 'util' ) ;
65const exec = util . promisify ( require ( 'child_process' ) . exec ) ;
76const zaf = require ( 'zip-a-folder' ) ;
@@ -13,8 +12,8 @@ const BROWSERS = {
1312 'Chromium' : 'manifest_chromium.json' ,
1413} ;
1514
16- function adjustManifest ( manifest ) {
17- const manifestFile = fs . readFileSync ( DEFAULT , 'utf8' ) ;
15+ async function adjustManifest ( manifest ) {
16+ const manifestFile = await fs . readFile ( DEFAULT , { encoding : 'utf8' } ) ;
1817 const data = JSON . parse ( manifestFile ) ;
1918 const browser = manifest . substring ( manifest . indexOf ( '_' ) + 1 , manifest . indexOf ( '.' ) ) ;
2019
@@ -30,7 +29,7 @@ function adjustManifest(manifest) {
3029 delete data [ 'applications' ] ;
3130 }
3231
33- fs . writeFileSync ( manifest , JSON . stringify ( data , null , 4 ) ) ;
32+ await fs . writeFile ( manifest , JSON . stringify ( data , null , 4 ) ) ;
3433 return `keepassxc-browser_${ data [ 'version' ] } _${ browser } .zip` ;
3534}
3635
@@ -42,15 +41,20 @@ async function updateTranslations() {
4241
4342( async ( ) => {
4443 await updateTranslations ( ) ;
45- fs . copyFileSync ( `${ DEST } /manifest.json` , `./${ DEFAULT } ` ) ;
44+ await fs . copyFile ( `${ DEST } /manifest.json` , `./${ DEFAULT } ` ) ;
4645
4746 for ( const browser in BROWSERS ) {
4847 console . log ( `KeePassXC-Browser: Creating extension package for ${ browser } ` ) ;
49- const fileName = adjustManifest ( BROWSERS [ browser ] ) ;
50- fs . copyFileSync ( BROWSERS [ browser ] , `${ DEST } /manifest.json` ) ;
51- extra . removeSync ( fileName ) ;
48+
49+ const fileName = await adjustManifest ( BROWSERS [ browser ] ) ;
50+ await fs . copyFile ( BROWSERS [ browser ] , `${ DEST } /manifest.json` ) ;
51+
52+ if ( await fs . exists ( fileName ) ) {
53+ await fs . rm ( fileName ) ;
54+ }
55+
5256 await zaf . zip ( DEST , fileName ) ;
53- extra . removeSync ( BROWSERS [ browser ] ) ;
57+ await fs . rm ( BROWSERS [ browser ] , { recursive : true } ) ;
5458 console . log ( 'Done' ) ;
5559 }
5660
0 commit comments