11'use strict' ;
22
3- import { writeFile } from 'node:fs/promises' ;
43import { basename , join } from 'node:path' ;
54
65import { checkIndirectReferences } from './utils/checkIndirectReferences.mjs' ;
76import { extractExports } from './utils/extractExports.mjs' ;
87import { findDefinitions } from './utils/findDefinitions.mjs' ;
98import getConfig from '../../utils/configuration/index.mjs' ;
10- import {
11- GITHUB_BLOB_URL ,
12- populate ,
13- } from '../../utils/configuration/templates.mjs' ;
9+ import { populate } from '../../utils/configuration/templates.mjs' ;
10+ import { withExt , writeFile } from '../../utils/file.mjs' ;
1411
1512/**
1613 * Generates the `apilinks.json` file.
@@ -33,16 +30,19 @@ export async function generate(input) {
3330 */
3431 const nameToLineNumberMap = { } ;
3532
36- // `http.js` -> `http`
37- const baseName = basename ( program . path , '.js' ) ;
33+ const fileName = basename ( program . path ) ;
34+ const baseName = withExt ( fileName ) ;
3835
3936 const exports = extractExports ( program , baseName , nameToLineNumberMap ) ;
4037
4138 findDefinitions ( program , baseName , nameToLineNumberMap , exports ) ;
4239
4340 checkIndirectReferences ( program , exports , nameToLineNumberMap ) ;
4441
45- const fullGitUrl = `${ populate ( GITHUB_BLOB_URL , config ) } lib/${ baseName } .js` ;
42+ const fullGitUrl = populate ( config . sourceURL , {
43+ ...config ,
44+ fileName,
45+ } ) ;
4646
4747 // Add the exports we found in this program to our output
4848 Object . keys ( nameToLineNumberMap ) . forEach ( key => {
0 commit comments