@@ -19,9 +19,9 @@ const colors = {
1919}
2020
2121const log = { } , { nc, dg, bw, by, bg, br } = colors
22- ; [ ' hash' , ' info' , ' working' , ' success' , ' error' ] . forEach ( lvl => log [ lvl ] = function ( msg ) {
23- const logColor = lvl == 'hash' ? dg : lvl == 'info' ? bw : lvl == 'working' ? by : lvl == 'success' ? bg : br ,
24- formattedMsg = logColor + ( log . endedWithLineBreak ? msg . trimStart ( ) : msg ) + nc
22+ const lvlColors = { hash : dg , info : bw , working : by , success : bg , error : br }
23+ Object . keys ( lvlColors ) . forEach ( lvl => log [ lvl ] = function ( msg ) {
24+ const formattedMsg = lvlColors [ lvl ] + ( log . endedWithLineBreak ? msg . trimStart ( ) : msg ) + nc
2525 console . log ( formattedMsg ) ; log . endedWithLineBreak = msg . toString ( ) . endsWith ( '\n' )
2626} )
2727
@@ -66,21 +66,21 @@ export async function findUserJS(dir = global.monorepoRoot) {
6666
6767export async function generateSRIhash ( resURL , algorithm = 'sha256' ) {
6868 const sriHash = ssri . fromData (
69- Buffer . from ( await ( await this . fetchData ( resURL ) ) . arrayBuffer ( ) ) , { algorithms : [ algorithm ] } ) . toString ( )
69+ Buffer . from ( await ( await fetch ( resURL ) ) . arrayBuffer ( ) ) , { algorithms : [ algorithm ] } ) . toString ( )
7070 this . log . hash ( `${ sriHash } \n` )
7171 return sriHash
7272}
7373
7474export async function getLatestCommitHash ( repo , path ) {
7575 const endpoint = `https://api.github.com/repos/${ repo } /commits` ,
76- latestCommitHash = ( await ( await this . fetchData ( `${ endpoint } ?path=${ path || '' } ` ) ) . json ( ) ) [ 0 ] ?. sha
76+ latestCommitHash = ( await ( await fetch ( `${ endpoint } ?path=${ path || '' } ` ) ) . json ( ) ) [ 0 ] ?. sha
7777 if ( latestCommitHash ) this . log . hash ( `${ latestCommitHash } \n` )
7878 return latestCommitHash
7979}
8080
8181export async function isValidResource ( resURL ) {
8282 try {
83- const resIsValid = ! ( await ( await this . fetchData ( resURL ) ) . text ( ) ) . startsWith ( 'Package size exceeded' )
83+ const resIsValid = ! ( await ( await fetch ( resURL ) ) . text ( ) ) . startsWith ( 'Package size exceeded' )
8484 if ( ! resIsValid ) this . log . error ( `\nInvalid resource: ${ resURL } \n` )
8585 return resIsValid
8686 } catch ( err ) { return this . log . error ( `\nCannot validate resource: ${ resURL } \n` ) }
0 commit comments