@@ -5,7 +5,7 @@ import { ensureDir, pathExists, readJson } from "fs-extra/esm";
55import Handlebars from "handlebars" ;
66import { readFile , writeFile } from "node:fs/promises" ;
77import { dirname , join , relative } from "node:path" ;
8- import { cwd } from "node:process" ;
8+ import { cwd as processCwd } from "node:process" ;
99import { fileURLToPath } from "node:url" ;
1010import { resolveConfig , type Config } from "./config.js" ;
1111import { FileReference } from "./file-reference.js" ;
@@ -53,12 +53,12 @@ export function defineGenerator({
5353 name,
5454} : GeneratorOptions ) : Generator {
5555 const generatorName = name ;
56- const generatorArgs = [ copy ( ) , log ( ) , ...args ]
56+ const generatorArgs = [ copy ( ) , cwd ( ) , log ( ) , ...args ]
5757 . map ( ( argFactory ) => argFactory ( generatorName ) )
5858 . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ;
5959
6060 async function run ( args : Args ) : Promise < void > {
61- const packagePath = cwd ( ) ;
61+ const packagePath = args . cwd ?? processCwd ( ) ;
6262 const packageJson : EmberPackageJson = await readJson (
6363 join ( packagePath , "package.json" ) ,
6464 ) ;
@@ -232,6 +232,14 @@ export function copy(): GeneratorArgFactory {
232232 } ) ;
233233}
234234
235+ export function cwd ( ) : GeneratorArgFactory {
236+ return ( ) => ( {
237+ description : "The current working directory to run the generator in" ,
238+ name : "cwd" ,
239+ type : "string" ,
240+ } ) ;
241+ }
242+
235243export function log ( ) : GeneratorArgFactory {
236244 return ( generatorName ) => ( {
237245 description : `Log the generated ${ generatorName } to the console, instead of writing it to disk` ,
0 commit comments