From 636c9484f9acc638c61ba47664fd0031155a1ef1 Mon Sep 17 00:00:00 2001 From: Dan Motzenbecker Date: Sat, 3 Oct 2015 20:34:10 -0400 Subject: [PATCH] readFile util function --- main.coffee | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/main.coffee b/main.coffee index fc2dd33..25ce07a 100644 --- a/main.coffee +++ b/main.coffee @@ -32,10 +32,14 @@ logErr = (err, color = 'red') -> process.exit 1 +readFile = (path) -> + fs.readFileSync path, encoding: 'ascii' + + editSync = (path, pairs) -> fs.writeFileSync path, pairs.reduce (contents, [rx, replacement]) -> contents.replace rx, replacement - , fs.readFileSync path, encoding: 'ascii' + , readFile path writeConfig = (config) -> @@ -51,7 +55,7 @@ writeConfig = (config) -> readConfig = -> try - JSON.parse fs.readFileSync '.natal' + JSON.parse readFile '.natal' catch {message} logErr \ if message.match /ENOENT/i