@@ -66,7 +66,22 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language}) => {
6666
6767 const meta = createLanguageMeta(language);
6868
69- const outputDirectory = path.resolve(rawOutputDirectory);
69+ const rawOutputPath = rawOutputDirectory;
70+ const outputExt = path.extname(rawOutputPath);
71+ const isFileOutput = !!outputExt;
72+ let outputDirectory = rawOutputPath;
73+ let singleFileDestination = null;
74+
75+ if (isFileOutput) {
76+ if (meta.isSingleFile()) {
77+ // Use the file path directly for single file languages
78+ outputDirectory = path.dirname(rawOutputPath);
79+ singleFileDestination = rawOutputPath;
80+ } else {
81+ throw new Error(`Invalid output path: ${rawOutputPath}. Output path must be a directory for languages that generate multiple files.`);
82+ }
83+ }
84+
7085 if (!fs.existsSync(outputDirectory)) {
7186 log(`Directory: ${outputDirectory} does not exist, creating...`);
7287 fs.mkdirSync(outputDirectory, { recursive: true });
@@ -95,7 +110,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language}) => {
95110 getType: meta.getType
96111 });
97112
98- const destination = path.join(outputDirectory, meta.getFileName());
113+ const destination = singleFileDestination || path.join(outputDirectory, meta.getFileName());
99114
100115 fs.writeFileSync(destination, content);
101116 log(`Added types to ${destination}`);
0 commit comments