From 652c217cd089bc67252fdd7b9d369cd124960b3b Mon Sep 17 00:00:00 2001 From: gregorybesson Date: Sun, 2 Oct 2016 18:30:18 +0200 Subject: [PATCH] refactoring: linting + Manager moved to core/manager --- src/cli/{models => core/manager}/Manager.js | 21 ++++----------------- src/cli/index.js | 2 +- 2 files changed, 5 insertions(+), 18 deletions(-) rename src/cli/{models => core/manager}/Manager.js (86%) diff --git a/src/cli/models/Manager.js b/src/cli/core/manager/Manager.js similarity index 86% rename from src/cli/models/Manager.js rename to src/cli/core/manager/Manager.js index 97821154..fb1b39cb 100644 --- a/src/cli/models/Manager.js +++ b/src/cli/core/manager/Manager.js @@ -5,12 +5,9 @@ import path from 'path' import { config, FileParser, - fileUtils, folderUtils, getSelectTemplateKeys -} from '../../cli' - -import * as redis from '../services/RedisClient' +} from '../../' let singleton = Symbol() let singletonEnforcer = Symbol() @@ -33,19 +30,11 @@ class Manager { } getList() { - if(config.redis.enable){ - redis.get().get('list', function(err, reply) { - this._list = JSON.parse(reply) - }) - } return this._list } setList(list) { - if(config.redis.enable){ - redis.get().set('list', JSON.stringify(list)) - } this._list = list return this @@ -53,7 +42,7 @@ class Manager { init() { this._whereKeys = [] - var p = new Promise((resolve, reject) => { + var p = new Promise((resolve) => { const pathTemplate = path.join(config.root, config.templates.url) getSelectTemplateKeys(pathTemplate) .then((whereKeys) => { @@ -75,10 +64,8 @@ class Manager { updateList() { this._list = FileParser.getAllFilesWithKeys(this._whereKeys) this._list.sort(FileParser.predicatBy('date', -1)) - if(config.redis.enable){ - redis.get().set('list', JSON.stringify(this._list)) - } - + console.log('Manager updated') + return this } diff --git a/src/cli/index.js b/src/cli/index.js index eb6a6867..eef0340f 100755 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -28,7 +28,7 @@ import { ifCond } from './handlebars/index' -import Manager from './models/Manager' +import Manager from './core/manager/Manager' import Page from './models/Page' import Handlebars from 'handlebars' import {getAttr, getEnclosingTags, escapeTextToRegex} from './helpers/regex-helper'