Skip to content

Commit

Permalink
- if output.file not exist use output.dir
Browse files Browse the repository at this point in the history
  • Loading branch information
cuyl committed Mar 8, 2019
1 parent f4ee39c commit 3fa40ec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
generateRound++;
},

_onwrite({ file }: OutputOptions): void
_onwrite({ file, dir }: OutputOptions): void
{
if (parsedConfig.options.declaration)
{
Expand All @@ -300,6 +300,7 @@ const typescript: PluginImpl<Partial<IOptions>> = (options) =>
});

const bundleFile = file;
const outputDir = dir;

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

0 comments on commit 3fa40ec

Please sign in to comment.