@@ -42,10 +42,11 @@ let containsHelp = false;
4242/**
4343 * Compute the options for this run.
4444 *
45- * @param {string[] } processArgv
45+ * @param {string[] } processArgv - An argument array (typically `process.argv`)
46+ * @param {Path } cwd - The current working directory (typically `process.cwd()`)
4647 * @returns {Options | never }
4748 */
48- function compute ( processArgv ) {
49+ function compute ( processArgv , cwd ) {
4950 containsHelp =
5051 processArgv . slice ( 2 ) . includes ( '--help' ) ||
5152 processArgv . slice ( 2 ) . includes ( '-h' ) ;
@@ -79,7 +80,7 @@ function compute(processArgv) {
7980 }
8081
8182 /** @type {Path | null } */
82- const elmJsonPath = findElmJsonPath ( args , subcommand ) ;
83+ const elmJsonPath = findElmJsonPath ( args , subcommand , cwd ) ;
8384 /** @type {Path | null } */
8485 const readmePath =
8586 elmJsonPath && path . join ( path . dirname ( elmJsonPath ) , 'README.md' ) ;
@@ -89,13 +90,13 @@ function compute(processArgv) {
8990 */
9091 function initPath ( ) {
9192 if ( args . config ) {
92- return path . resolve ( process . cwd ( ) , args . config ) ;
93+ return path . resolve ( cwd , args . config ) ;
9394 }
9495
9596 try {
9697 return path . join ( projectToReview ( ) , 'review' ) ;
9798 } catch {
98- return path . join ( process . cwd ( ) , 'review' ) ;
99+ return path . join ( cwd , 'review' ) ;
99100 }
100101 }
101102
@@ -111,7 +112,7 @@ function compute(processArgv) {
111112
112113If you wish to run elm-review from outside your project,
113114try re-running it with ${ chalk . cyan ( '--elmjson <path-to-elm.json>' ) } .` ,
114- path . relative ( process . cwd ( ) , 'elm.json' )
115+ path . relative ( cwd , 'elm.json' )
115116 ) ;
116117 }
117118
@@ -163,7 +164,7 @@ try re-running it with ${chalk.cyan('--elmjson <path-to-elm.json>')}.`,
163164 */
164165 function userSrc ( ) {
165166 return args . config
166- ? path . resolve ( process . cwd ( ) , args . config )
167+ ? path . resolve ( cwd , args . config )
167168 : path . join ( projectToReview ( ) , 'review' ) ;
168169 }
169170
@@ -258,7 +259,7 @@ try re-running it with ${chalk.cyan('--elmjson <path-to-elm.json>')}.`,
258259 : null ,
259260
260261 // PATHS - REVIEW APPLICATION
261-
262+ cwd ,
262263 userSrc,
263264 usedConfig : Boolean ( args . config ) ,
264265 template,
@@ -271,7 +272,7 @@ try re-running it with ${chalk.cyan('--elmjson <path-to-elm.json>')}.`,
271272 path . join ( elmStuffFolder ( ) , 'review-applications' , `${ appHash } .js` ) ,
272273 elmParserPath : ( elmSyntaxVersion ) =>
273274 path . resolve (
274- process . cwd ( ) ,
275+ cwd ,
275276 elmStuffFolder ( ) ,
276277 'elm-parser' ,
277278 `elm-syntax-v${ elmSyntaxVersion } ${ args . debug ? '-debug' : '' } .js`
@@ -391,9 +392,10 @@ ${Flags.buildFlag(subcommand, Flags.templateFlag)}`
391392/**
392393 * @param {ParsedArgs } args
393394 * @param {Subcommand | null } subcommand
395+ * @param {Path } cwd
394396 * @returns {Path | null }
395397 */
396- function findElmJsonPath ( args , subcommand ) {
398+ function findElmJsonPath ( args , subcommand , cwd ) {
397399 // eslint-disable-next-line @typescript-eslint/no-unsafe-return -- Casting is ugly.
398400 if ( args . elmjson ) return args . elmjson ;
399401 // Shortcutting the search for elm.json when `--help` since we won't need it
@@ -409,7 +411,7 @@ function findElmJsonPath(args, subcommand) {
409411 return null ;
410412 }
411413
412- return findUp . sync ( 'elm.json' ) ?? null ;
414+ return findUp . sync ( 'elm.json' , { cwd } ) ?? null ;
413415}
414416
415417/**
0 commit comments