Skip to content

Commit add58b9

Browse files
committed
Improved error output
Signed-off-by: Jaid <jaid.jsx@gmail.com>
1 parent 117211f commit add58b9

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/index.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ const getHtmlConfigPath = (compilation, configBase, template, options, configDir
2323
}
2424
const configPath = path.join(configDir, "jsdoc-config-html.json")
2525
fs.writeJsonSync(configPath, config)
26-
return configPath
26+
return {
27+
configPath,
28+
config,
29+
}
2730
}
2831

2932
const getTsdConfigPath = (compilation, configBase, template, options, configDir) => {
@@ -44,7 +47,10 @@ const getTsdConfigPath = (compilation, configBase, template, options, configDir)
4447
}
4548
const configPath = path.join(configDir, "jsdoc-config-tsd.json")
4649
fs.writeJsonSync(configPath, config)
47-
return configPath
50+
return {
51+
configPath,
52+
config,
53+
}
4854
}
4955

5056
export default class {
@@ -182,17 +188,23 @@ export default class {
182188
]
183189

184190
for (const {name, modulePath, configFactory} of setups) {
185-
const configPath = configFactory(compilation, configBase, modulePath, this.options, tempDir)
191+
const {configPath, config} = configFactory(compilation, configBase, modulePath, this.options, tempDir)
186192
debug(`${name}: Calling jsdoc-api with entry point ${compiler.options.entry} and configuration ${configPath}`)
187193
renderSync({
188194
files: compiler.options.entry,
189195
configure: configPath,
190196
})
197+
if (!fs.existsSync(config.opts.destination)) {
198+
throw new Error(`JSDoc for ${name} has run without any error, but ${config.opts.destination} does not exist!`)
199+
}
191200
}
192201

193202
if (this.options.autoTsdOutputFile) {
194203
debug(`Copying ${this.options.autoTsdOutputFile} to ${path.join(compiler.outputPath, this.options.autoTsdOutputFile |> path.basename)}`)
195-
const tsdContent = fs.readFileSync(this.options.autoTsdOutputFile)
204+
const tsdContent = fs.readFileSync(this.options.autoTsdOutputFile, "utf8")
205+
if (!tsdContent.trim().length) {
206+
throw new Error(`TSD file ${this.options.autoTsdOutputFile} is empty!`)
207+
}
196208
compilation.assets[path.basename(this.options.autoTsdOutputFile)] = {
197209
source: () => tsdContent,
198210
size: () => tsdContent.length,

0 commit comments

Comments
 (0)