From e735095efe5ee94ccbd8ddf1345cb9a2bc810d77 Mon Sep 17 00:00:00 2001 From: Roojay Date: Mon, 1 Apr 2019 15:50:32 +0800 Subject: [PATCH] fixed: open empty file error. --- css_wrap.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/css_wrap.js b/css_wrap.js index c9533d9..3804c63 100644 --- a/css_wrap.js +++ b/css_wrap.js @@ -41,10 +41,15 @@ var skip: null }, options || {}); if (fs.existsSync(path.resolve(string))) { - string = fs.readFileSync(string).toString(); + try { + string = fs.readFileSync(string).toString() + } catch (error) { + console.log('empty file skipped!'); + return ''; + } } var css = css_parse( string ); css.stylesheet.rules = processRules( css.stylesheet.rules, options ); return css_stringify( css ); }; -module.exports = css_wrap; \ No newline at end of file +module.exports = css_wrap;