From 394bfb9de7f1283865227ee534bf81b77a7e053c Mon Sep 17 00:00:00 2001 From: Josh Schneider Date: Thu, 29 Mar 2018 09:07:37 -0700 Subject: [PATCH] Fix errors when file type not found for pattern I kept getting errors if I didn't define scss or js files for patterns, if I had those types in my tabsToAdd option. I think this is a decent fix, but not sure why existing tabFileNameStats.isFile() was not preventing the attempt to copy a non-existent file. In this case, tabFileNameStats is definitively set to null unless the statSync succeeds in the try block. --- src/tab-loader.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/tab-loader.js b/src/tab-loader.js index 102295b..54d7d93 100644 --- a/src/tab-loader.js +++ b/src/tab-loader.js @@ -38,8 +38,10 @@ function findTab(patternlab, pattern) { //look for a custom filetype for this template try { var tabFileName = path.resolve(customFileTypePath); + var tabFileNameStats = null; try { - var tabFileNameStats = fs.statSync(tabFileName); + var _stats = fs.statSync(tabFileName); + _stats && (tabFileNameStats = _stats); } catch (err) { //not a file - move on quietly }