11import { readdirSync } from 'fs' ;
22import { resolve } from 'path' ;
3- import relative from 'require-relative ' ;
3+ import { cwd } from 'process ' ;
44import { handleError } from '../logging' ;
55
66const DEFAULT_CONFIG_BASE = 'rollup.config' ;
77
88export function getConfigPath ( commandConfig : string | true ) : string {
9- const cwd = process . cwd ( ) ;
109 if ( commandConfig === true ) {
1110 return resolve ( findConfigFileNameInCwd ( ) ) ;
1211 }
1312 if ( commandConfig . slice ( 0 , 5 ) === 'node:' ) {
1413 const pkgName = commandConfig . slice ( 5 ) ;
1514 try {
16- return relative . resolve ( `rollup-config-${ pkgName } ` , cwd ) ;
15+ return require . resolve ( `rollup-config-${ pkgName } ` , { paths : [ cwd ( ) ] } ) ;
1716 } catch {
1817 try {
19- return relative . resolve ( pkgName , cwd ) ;
18+ return require . resolve ( pkgName , { paths : [ cwd ( ) ] } ) ;
2019 } catch ( err : any ) {
2120 if ( err . code === 'MODULE_NOT_FOUND' ) {
2221 handleError ( {
@@ -32,7 +31,7 @@ export function getConfigPath(commandConfig: string | true): string {
3231}
3332
3433function findConfigFileNameInCwd ( ) : string {
35- const filesInWorkingDir = new Set ( readdirSync ( process . cwd ( ) ) ) ;
34+ const filesInWorkingDir = new Set ( readdirSync ( cwd ( ) ) ) ;
3635 for ( const extension of [ 'mjs' , 'cjs' , 'ts' ] ) {
3736 const fileName = `${ DEFAULT_CONFIG_BASE } .${ extension } ` ;
3837 if ( filesInWorkingDir . has ( fileName ) ) return fileName ;
0 commit comments