@@ -4,7 +4,17 @@ const fs = require('fs/promises')
4
4
const { glob } = require ( 'glob' )
5
5
const path = require ( 'path' )
6
6
const log = require ( 'proc-log' )
7
- const hostedGitInfo = require ( 'hosted-git-info' )
7
+
8
+ /**
9
+ * @type {import('hosted-git-info') }
10
+ */
11
+ let _hostedGitInfo
12
+ function lazyHostedGitInfo ( ) {
13
+ if ( ! _hostedGitInfo ) {
14
+ _hostedGitInfo = require ( 'hosted-git-info' )
15
+ }
16
+ return _hostedGitInfo
17
+ }
8
18
9
19
// used to be npm-normalize-package-bin
10
20
function normalizePackageBin ( pkg , changes ) {
@@ -445,7 +455,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
445
455
}
446
456
}
447
457
if ( data . repository . url ) {
448
- const hosted = hostedGitInfo . fromUrl ( data . repository . url )
458
+ const hosted = lazyHostedGitInfo ( ) . fromUrl ( data . repository . url )
449
459
let r
450
460
if ( hosted ) {
451
461
if ( hosted . getDefaultRepresentation ( ) === 'shortcut' ) {
@@ -505,7 +515,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
505
515
changes ?. push ( `Removed invalid "${ deps } .${ d } "` )
506
516
delete data [ deps ] [ d ]
507
517
}
508
- const hosted = hostedGitInfo . fromUrl ( data [ deps ] [ d ] ) ?. toString ( )
518
+ const hosted = lazyHostedGitInfo ( ) . fromUrl ( data [ deps ] [ d ] ) ?. toString ( )
509
519
if ( hosted && hosted !== data [ deps ] [ d ] ) {
510
520
changes ?. push ( `Normalized git reference to "${ deps } .${ d } "` )
511
521
data [ deps ] [ d ] = hosted . toString ( )
0 commit comments