From 9fb86bf32e4f508a5c2acb6e3658eb67d42fb96a Mon Sep 17 00:00:00 2001 From: joe fleming Date: Fri, 5 Apr 2019 15:00:18 -0700 Subject: [PATCH] fix: fail on ident read remove getRootFileContents util, easily replaced in the one place it's used --- src/utils.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/utils.js b/src/utils.js index 4e47400..6c00229 100644 --- a/src/utils.js +++ b/src/utils.js @@ -27,12 +27,11 @@ exports.getFileContents = (filePath, opts = {}) => { return content; }; -exports.getRootFileContents = (filename, opts = {}) => { - return exports.getFileContents(path.join(exports.getRootPath(), filename), opts); -}; - exports.getIdent = () => { - const { name } = exports.getRootFileContents('package.json', { format: 'json' }); + const { name } = exports.getFileContents(path.join(exports.getRootPath(), 'package.json'), { + format: 'json', + }); + if (!name) throw new Error('Unable to read project name from package.json'); return name; };