Skip to content

Commit 3fa40ec

Browse files
committed
- if output.file not exist use output.dir
1 parent f4ee39c commit 3fa40ec

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
283283
generateRound++;
284284
},
285285

286-
_onwrite({ file }: OutputOptions): void
286+
_onwrite({ file, dir }: OutputOptions): void
287287
{
288288
if (parsedConfig.options.declaration)
289289
{
@@ -300,6 +300,7 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
300300
});
301301

302302
const bundleFile = file;
303+
const outputDir = dir;
303304

304305
const writeDeclaration = (key: string, extension: string, entry?: tsTypes.OutputFile) =>
305306
{
@@ -313,12 +314,12 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
313314
let writeToPath: string;
314315
// If for some reason no 'dest' property exists or if 'useTsconfigDeclarationDir' is given in the plugin options,
315316
// use the path provided by Typescript's LanguageService.
316-
if (!bundleFile || pluginOptions.useTsconfigDeclarationDir)
317+
if ((!bundleFile && !outputDir) || pluginOptions.useTsconfigDeclarationDir)
317318
writeToPath = fileName;
318319
else
319320
{
320321
// Otherwise, take the directory name from the path and make sure it is absolute.
321-
const destDirname = dirname(bundleFile);
322+
const destDirname = bundleFile ? dirname(bundleFile) : <string>outputDir;
322323
const destDirectory = isAbsolute(destDirname) ? destDirname : join(process.cwd(), destDirname);
323324
writeToPath = join(destDirectory, relative(process.cwd(), fileName));
324325
}

0 commit comments

Comments
 (0)