Skip to content

Commit

Permalink
support absolute filenames with gen
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn committed Oct 19, 2023
1 parent d71fc3a commit 40a427e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/seven-paws-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@grogarden/gro': patch
---

support absolute filenames with gen
3 changes: 2 additions & 1 deletion src/lib/gen.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {Logger} from '@grogarden/util/log.js';
import {join, basename, dirname} from 'node:path';
import {join, basename, dirname, isAbsolute} from 'node:path';
import {z} from 'zod';

import {gen_module_meta, to_gen_module_type} from './gen_module.js';
Expand Down Expand Up @@ -93,6 +93,7 @@ const to_output_file_id = (origin_id: SourceId, raw_file_name: string | undefine
throw Error(`Output file name cannot be an empty string`);
}
const filename = raw_file_name || to_output_file_name(basename(origin_id));
if (isAbsolute(filename)) return filename;
const dir = dirname(origin_id);
const output_file_id = join(dir, filename);
if (output_file_id === origin_id) {
Expand Down

0 comments on commit 40a427e

Please sign in to comment.