@@ -125,7 +125,7 @@ const { Console } = require('console');
125
125
const CJSModule = require ( 'internal/modules/cjs/loader' ) . Module ;
126
126
let _builtinLibs = ArrayPrototypeFilter (
127
127
CJSModule . builtinModules ,
128
- ( e ) => ! StringPrototypeStartsWith ( e , '_' ) && ! StringPrototypeIncludes ( e , '/' )
128
+ ( e ) => ! StringPrototypeStartsWith ( e , '_' ) ,
129
129
) ;
130
130
const nodeSchemeBuiltinLibs = ArrayPrototypeMap (
131
131
_builtinLibs , ( lib ) => `node:${ lib } ` ) ;
@@ -1287,135 +1287,133 @@ function complete(line, callback) {
1287
1287
if ( completeOn . length ) {
1288
1288
filter = completeOn ;
1289
1289
}
1290
- } else if ( RegExpPrototypeTest ( requireRE , line ) &&
1291
- this . allowBlockingCompletions ) {
1290
+ } else if ( RegExpPrototypeTest ( requireRE , line ) ) {
1292
1291
// require('...<Tab>')
1293
- const extensions = ObjectKeys ( this . context . require . extensions ) ;
1294
- const indexes = ArrayPrototypeMap ( extensions ,
1295
- ( extension ) => `index${ extension } ` ) ;
1296
- ArrayPrototypePush ( indexes , 'package.json' , 'index' ) ;
1297
-
1298
1292
const match = StringPrototypeMatch ( line , requireRE ) ;
1299
1293
completeOn = match [ 1 ] ;
1300
- const subdir = match [ 2 ] || '' ;
1301
1294
filter = completeOn ;
1302
- group = [ ] ;
1303
- let paths = [ ] ;
1304
-
1305
- if ( completeOn === '.' ) {
1306
- group = [ './' , '../' ] ;
1307
- } else if ( completeOn === '..' ) {
1308
- group = [ '../' ] ;
1309
- } else if ( RegExpPrototypeTest ( / ^ \. \. ? \/ / , completeOn ) ) {
1310
- paths = [ process . cwd ( ) ] ;
1311
- } else {
1312
- paths = ArrayPrototypeConcat ( module . paths , CJSModule . globalPaths ) ;
1313
- }
1295
+ if ( this . allowBlockingCompletions ) {
1296
+ const subdir = match [ 2 ] || '' ;
1297
+ const extensions = ObjectKeys ( this . context . require . extensions ) ;
1298
+ const indexes = ArrayPrototypeMap ( extensions ,
1299
+ ( extension ) => `index${ extension } ` ) ;
1300
+ ArrayPrototypePush ( indexes , 'package.json' , 'index' ) ;
1301
+
1302
+ group = [ ] ;
1303
+ let paths = [ ] ;
1304
+
1305
+ if ( completeOn === '.' ) {
1306
+ group = [ './' , '../' ] ;
1307
+ } else if ( completeOn === '..' ) {
1308
+ group = [ '../' ] ;
1309
+ } else if ( RegExpPrototypeTest ( / ^ \. \. ? \/ / , completeOn ) ) {
1310
+ paths = [ process . cwd ( ) ] ;
1311
+ } else {
1312
+ paths = ArrayPrototypeConcat ( module . paths , CJSModule . globalPaths ) ;
1313
+ }
1314
1314
1315
- ArrayPrototypeForEach ( paths , ( dir ) => {
1316
- dir = path . resolve ( dir , subdir ) ;
1317
- const dirents = gracefulReaddir ( dir , { withFileTypes : true } ) || [ ] ;
1318
- ArrayPrototypeForEach ( dirents , ( dirent ) => {
1319
- if ( RegExpPrototypeTest ( versionedFileNamesRe , dirent . name ) ||
1320
- dirent . name === '.npm' ) {
1321
- // Exclude versioned names that 'npm' installs.
1322
- return ;
1323
- }
1324
- const extension = path . extname ( dirent . name ) ;
1325
- const base = StringPrototypeSlice ( dirent . name , 0 , - extension . length ) ;
1326
- if ( ! dirent . isDirectory ( ) ) {
1327
- if ( StringPrototypeIncludes ( extensions , extension ) &&
1328
- ( ! subdir || base !== 'index' ) ) {
1329
- ArrayPrototypePush ( group , `${ subdir } ${ base } ` ) ;
1315
+ ArrayPrototypeForEach ( paths , ( dir ) => {
1316
+ dir = path . resolve ( dir , subdir ) ;
1317
+ const dirents = gracefulReaddir ( dir , { withFileTypes : true } ) || [ ] ;
1318
+ ArrayPrototypeForEach ( dirents , ( dirent ) => {
1319
+ if ( RegExpPrototypeTest ( versionedFileNamesRe , dirent . name ) ||
1320
+ dirent . name === '.npm' ) {
1321
+ // Exclude versioned names that 'npm' installs.
1322
+ return ;
1330
1323
}
1331
- return ;
1332
- }
1333
- ArrayPrototypePush ( group , `${ subdir } ${ dirent . name } /` ) ;
1334
- const absolute = path . resolve ( dir , dirent . name ) ;
1335
- if ( ArrayPrototypeSome (
1336
- gracefulReaddir ( absolute ) || [ ] ,
1337
- ( subfile ) => ArrayPrototypeIncludes ( indexes , subfile )
1338
- ) ) {
1339
- ArrayPrototypePush ( group , `${ subdir } ${ dirent . name } ` ) ;
1340
- }
1324
+ const extension = path . extname ( dirent . name ) ;
1325
+ const base = StringPrototypeSlice ( dirent . name , 0 , - extension . length ) ;
1326
+ if ( ! dirent . isDirectory ( ) ) {
1327
+ if ( StringPrototypeIncludes ( extensions , extension ) &&
1328
+ ( ! subdir || base !== 'index' ) ) {
1329
+ ArrayPrototypePush ( group , `${ subdir } ${ base } ` ) ;
1330
+ }
1331
+ return ;
1332
+ }
1333
+ ArrayPrototypePush ( group , `${ subdir } ${ dirent . name } /` ) ;
1334
+ const absolute = path . resolve ( dir , dirent . name ) ;
1335
+ if ( ArrayPrototypeSome (
1336
+ gracefulReaddir ( absolute ) || [ ] ,
1337
+ ( subfile ) => ArrayPrototypeIncludes ( indexes , subfile )
1338
+ ) ) {
1339
+ ArrayPrototypePush ( group , `${ subdir } ${ dirent . name } ` ) ;
1340
+ }
1341
+ } ) ;
1341
1342
} ) ;
1342
- } ) ;
1343
- if ( group . length ) {
1344
- ArrayPrototypePush ( completionGroups , group ) ;
1343
+ if ( group . length ) {
1344
+ ArrayPrototypePush ( completionGroups , group ) ;
1345
+ }
1345
1346
}
1346
1347
1347
- if ( ! subdir ) {
1348
- ArrayPrototypePush ( completionGroups , _builtinLibs , nodeSchemeBuiltinLibs ) ;
1349
- }
1350
- } else if ( RegExpPrototypeTest ( importRE , line ) &&
1351
- this . allowBlockingCompletions ) {
1348
+ ArrayPrototypePush ( completionGroups , _builtinLibs , nodeSchemeBuiltinLibs ) ;
1349
+ } else if ( RegExpPrototypeTest ( importRE , line ) ) {
1352
1350
// import('...<Tab>')
1353
- // File extensions that can be imported:
1354
- const extensions = ObjectKeys (
1355
- getOptionValue ( '--experimental-specifier-resolution' ) === 'node' ?
1356
- legacyExtensionFormatMap :
1357
- extensionFormatMap ) ;
1358
-
1359
- // Only used when loading bare module specifiers from `node_modules`:
1360
- const indexes = ArrayPrototypeMap ( extensions , ( ext ) => `index${ ext } ` ) ;
1361
- ArrayPrototypePush ( indexes , 'package.json' ) ;
1362
-
1363
1351
const match = StringPrototypeMatch ( line , importRE ) ;
1364
1352
completeOn = match [ 1 ] ;
1365
- const subdir = match [ 2 ] || '' ;
1366
1353
filter = completeOn ;
1367
- group = [ ] ;
1368
- let paths = [ ] ;
1369
- if ( completeOn === '.' ) {
1370
- group = [ './' , '../' ] ;
1371
- } else if ( completeOn === '..' ) {
1372
- group = [ '../' ] ;
1373
- } else if ( RegExpPrototypeTest ( / ^ \. \. ? \/ / , completeOn ) ) {
1374
- paths = [ process . cwd ( ) ] ;
1375
- } else {
1376
- paths = ArrayPrototypeSlice ( module . paths ) ;
1377
- }
1354
+ if ( this . allowBlockingCompletions ) {
1355
+ const subdir = match [ 2 ] || '' ;
1356
+ // File extensions that can be imported:
1357
+ const extensions = ObjectKeys (
1358
+ getOptionValue ( '--experimental-specifier-resolution' ) === 'node' ?
1359
+ legacyExtensionFormatMap :
1360
+ extensionFormatMap ) ;
1361
+
1362
+ // Only used when loading bare module specifiers from `node_modules`:
1363
+ const indexes = ArrayPrototypeMap ( extensions , ( ext ) => `index${ ext } ` ) ;
1364
+ ArrayPrototypePush ( indexes , 'package.json' ) ;
1365
+
1366
+ group = [ ] ;
1367
+ let paths = [ ] ;
1368
+ if ( completeOn === '.' ) {
1369
+ group = [ './' , '../' ] ;
1370
+ } else if ( completeOn === '..' ) {
1371
+ group = [ '../' ] ;
1372
+ } else if ( RegExpPrototypeTest ( / ^ \. \. ? \/ / , completeOn ) ) {
1373
+ paths = [ process . cwd ( ) ] ;
1374
+ } else {
1375
+ paths = ArrayPrototypeSlice ( module . paths ) ;
1376
+ }
1378
1377
1379
- ArrayPrototypeForEach ( paths , ( dir ) => {
1380
- dir = path . resolve ( dir , subdir ) ;
1381
- const isInNodeModules = path . basename ( dir ) === 'node_modules' ;
1382
- const dirents = gracefulReaddir ( dir , { withFileTypes : true } ) || [ ] ;
1383
- ArrayPrototypeForEach ( dirents , ( dirent ) => {
1384
- const { name } = dirent ;
1385
- if ( RegExpPrototypeTest ( versionedFileNamesRe , name ) ||
1386
- name === '.npm' ) {
1387
- // Exclude versioned names that 'npm' installs.
1388
- return ;
1389
- }
1378
+ ArrayPrototypeForEach ( paths , ( dir ) => {
1379
+ dir = path . resolve ( dir , subdir ) ;
1380
+ const isInNodeModules = path . basename ( dir ) === 'node_modules' ;
1381
+ const dirents = gracefulReaddir ( dir , { withFileTypes : true } ) || [ ] ;
1382
+ ArrayPrototypeForEach ( dirents , ( dirent ) => {
1383
+ const { name } = dirent ;
1384
+ if ( RegExpPrototypeTest ( versionedFileNamesRe , name ) ||
1385
+ name === '.npm' ) {
1386
+ // Exclude versioned names that 'npm' installs.
1387
+ return ;
1388
+ }
1390
1389
1391
- if ( ! dirent . isDirectory ( ) ) {
1392
- const extension = path . extname ( name ) ;
1393
- if ( StringPrototypeIncludes ( extensions , extension ) ) {
1394
- ArrayPrototypePush ( group , `${ subdir } ${ name } ` ) ;
1390
+ if ( ! dirent . isDirectory ( ) ) {
1391
+ const extension = path . extname ( name ) ;
1392
+ if ( StringPrototypeIncludes ( extensions , extension ) ) {
1393
+ ArrayPrototypePush ( group , `${ subdir } ${ name } ` ) ;
1394
+ }
1395
+ return ;
1395
1396
}
1396
- return ;
1397
- }
1398
1397
1399
- ArrayPrototypePush ( group , `${ subdir } ${ name } /` ) ;
1400
- if ( ! subdir && isInNodeModules ) {
1401
- const absolute = path . resolve ( dir , name ) ;
1402
- const subfiles = gracefulReaddir ( absolute ) || [ ] ;
1403
- if ( ArrayPrototypeSome ( subfiles , ( subfile ) => {
1404
- return ArrayPrototypeIncludes ( indexes , subfile ) ;
1405
- } ) ) {
1406
- ArrayPrototypePush ( group , `${ subdir } ${ name } ` ) ;
1398
+ ArrayPrototypePush ( group , `${ subdir } ${ name } /` ) ;
1399
+ if ( ! subdir && isInNodeModules ) {
1400
+ const absolute = path . resolve ( dir , name ) ;
1401
+ const subfiles = gracefulReaddir ( absolute ) || [ ] ;
1402
+ if ( ArrayPrototypeSome ( subfiles , ( subfile ) => {
1403
+ return ArrayPrototypeIncludes ( indexes , subfile ) ;
1404
+ } ) ) {
1405
+ ArrayPrototypePush ( group , `${ subdir } ${ name } ` ) ;
1406
+ }
1407
1407
}
1408
- }
1408
+ } ) ;
1409
1409
} ) ;
1410
- } ) ;
1411
1410
1412
- if ( group . length ) {
1413
- ArrayPrototypePush ( completionGroups , group ) ;
1411
+ if ( group . length ) {
1412
+ ArrayPrototypePush ( completionGroups , group ) ;
1413
+ }
1414
1414
}
1415
1415
1416
- if ( ! subdir ) {
1417
- ArrayPrototypePush ( completionGroups , _builtinLibs , nodeSchemeBuiltinLibs ) ;
1418
- }
1416
+ ArrayPrototypePush ( completionGroups , _builtinLibs , nodeSchemeBuiltinLibs ) ;
1419
1417
} else if ( RegExpPrototypeTest ( fsAutoCompleteRE , line ) &&
1420
1418
this . allowBlockingCompletions ) {
1421
1419
( { 0 : completionGroups , 1 : completeOn } = completeFSFunctions ( line ) ) ;
0 commit comments