Skip to content

Commit 5b35cc5

Browse files
authored
Remove unecessary TypeError on build
The following error occurs when running tcm: [Error] TypeError: Cannot read property 'forEach' of undefined After some debugging, it became clear that this is caused by a missing if statement checking if the messageList exists or not. If the error is there due to some reason unknown to me, please elaborate :)
1 parent 2d426d7 commit 5b35cc5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/cli.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ function writeFile(f) {
3030
.then(content => {
3131
if (!argv.s) {
3232
console.log('Wrote ' + chalk.green(content.outputFilePath));
33-
content.messageList.forEach(message => {
34-
console.warn(chalk.yellow('[Warn] ' + message));
35-
});
33+
if (content.messageList && content.messageList.length) {
34+
content.messageList.forEach(message => {
35+
console.warn(chalk.yellow('[Warn] ' + message));
36+
});
37+
}
3638
}
3739
})
3840
.catch(reason => console.error(chalk.red('[Error] ' + reason)));

0 commit comments

Comments
 (0)