From 2e7d3d75844050090b938acaf9bd24c8b198c9f5 Mon Sep 17 00:00:00 2001 From: Luke Preston Date: Mon, 22 Feb 2016 11:09:38 +0000 Subject: [PATCH 1/2] updating antie.js --- node/antie.js | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/node/antie.js b/node/antie.js index 213052ae..9e87ff57 100644 --- a/node/antie.js +++ b/node/antie.js @@ -1,9 +1,27 @@ var fs = require('fs') +function fileExistsSync(path) { + try { + fs.lstatSync(path); + return true; + } catch (e) { + return false; + } +} + +function fileExists(path, callback) { + try { + fs.lstat(path); + callback(true); + } catch (e) { + callback(false); + } +} + module.exports = { - getPageStrategyElement: function(pageStrategy, element) { + getPageStrategyElementSync: function(pageStrategy, element) { var pageStrategyPath = __dirname + '/../config/pagestrategy/' + pageStrategy + '/' + element; - if (!fs.existsSync(pageStrategyPath)) { + if (!fileExistsSync(pageStrategyPath)) { return { noSuchStrategy: "file does not exist: " + pageStrategyPath } @@ -11,5 +29,20 @@ module.exports = { return { data: fs.readFileSync(pageStrategyPath).toString() } + }, + getPageStrategyElement: function(pageStrategy, element, callback) { + var pageStrategyPath = __dirname + '/../config/pagestrategy/' + pageStrategy + '/' + element; + + fs.readFile(pageStrategyPath, function(err, data) { + if (err !== null) { + callback({ + noSuchStrategy: "file does not exist: " + pageStrategyPath + }) + } else { + callback({ + data: data.toString() + }) + } + }) } } From 430d1a67b52440b3ea6d7b7d14ba0b0a109ec3c1 Mon Sep 17 00:00:00 2001 From: Luke Preston Date: Mon, 22 Feb 2016 11:12:11 +0000 Subject: [PATCH 2/2] removing unused file --- node/antie.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/node/antie.js b/node/antie.js index 9e87ff57..2593005e 100644 --- a/node/antie.js +++ b/node/antie.js @@ -9,15 +9,6 @@ function fileExistsSync(path) { } } -function fileExists(path, callback) { - try { - fs.lstat(path); - callback(true); - } catch (e) { - callback(false); - } -} - module.exports = { getPageStrategyElementSync: function(pageStrategy, element) { var pageStrategyPath = __dirname + '/../config/pagestrategy/' + pageStrategy + '/' + element;