11import ChromeExtension from 'crx' ;
22import { readFile , writeFile } from 'fs/promises' ;
3- import { join , getVersion , getOutputFile } from '../config.mjs' ;
3+ import { getOutputFile , getVersion , join } from '../config.mjs' ;
44
55async function createCrx ( fileContent , keyContent ) {
66 if ( ! keyContent ) {
@@ -18,16 +18,29 @@ async function createCrx(fileContent, keyContent) {
1818 return crxBuffer ;
1919}
2020
21- async function packCrx ( sourcePath , zipPath , releasePath , browserConfig , itemConfig ) {
21+ async function packCrx (
22+ sourcePath ,
23+ zipPath ,
24+ releasePath ,
25+ browserConfig ,
26+ itemConfig ,
27+ ) {
2228 const fileContent = await readFile ( zipPath ) ;
2329 if ( typeof process . env [ itemConfig . priv_key ] === 'undefined' ) {
2430 throw new Error ( `${ itemConfig . priv_key } not found` ) ;
2531 }
26- const content = await createCrx ( fileContent , process . env [ itemConfig . priv_key ] ) ;
27- const fileName = getOutputFile ( itemConfig . browser , await getVersion ( sourcePath ) , 'crx' ) ;
32+ const content = await createCrx (
33+ fileContent ,
34+ process . env [ itemConfig . priv_key ] ,
35+ ) ;
36+ const fileName = getOutputFile (
37+ itemConfig . browser ,
38+ await getVersion ( sourcePath ) ,
39+ 'crx' ,
40+ ) ;
2841 const out = join ( releasePath , fileName ) ;
2942 await writeFile ( out , content ) ;
30- const idFile = join ( outputDir , `${ fileName } -id.txt` ) ;
43+ const idFile = join ( releasePath , `${ fileName } -id.txt` ) ;
3144 await writeFile ( idFile , itemConfig . id ) ;
3245 return out ;
3346}
0 commit comments