Skip to content

Commit 3d46f56

Browse files
committed
feat: support cwd as generate argument
1 parent c30661a commit 3d46f56

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface Language<A> {
1616
(documents: Record<string, A>): Either<unknown, FSEntity>;
1717
}
1818
export interface GenerateOptions<A> {
19+
readonly cwd?: string;
1920
readonly out: string;
2021
readonly spec: string;
2122
readonly decoder: Decoder<unknown, A>;
@@ -29,7 +30,7 @@ const getUnsafe: <E, A>(e: Either<E, A>) => A = either.fold(e => {
2930

3031
export const generate = <A>(options: GenerateOptions<A>): TaskEither<unknown, void> =>
3132
taskEither.tryCatch(async () => {
32-
const cwd = process.cwd();
33+
const cwd = options.cwd || process.cwd();
3334
const out = path.isAbsolute(options.out) ? options.out : path.resolve(cwd, options.out);
3435
const spec = path.isAbsolute(options.spec) ? options.spec : path.resolve(cwd, options.spec);
3536
log('Processing', spec);

0 commit comments

Comments
 (0)