Skip to content

Commit

Permalink
Code lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ilterra committed Nov 15, 2020
1 parent 78c8db8 commit 08b6d67
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ const R = require('ramda');
const Result = require('folktale/data/result');
const utils = require('./service/utils');

const initializeContentStructure = filePath => ({
const initializeContentStructure = (filePath) => ({
path: filePath,
metadata: {},
content: filesystem.safeGetFileContent(filePath)
content: filesystem.safeGetFileContent(filePath),
});

/**
* build :: String -> void
* Build the Barlafus blog
*/
const build = projectDir => {
const build = (projectDir) => {
const logger = utils.getLogger(projectDir);
const settings = utils.loadSettings(projectDir);
const blogDraftsDir = path.join(projectDir, 'website', 'content', 'drafts', 'blog');
Expand Down
10 changes: 5 additions & 5 deletions lib/service/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ const Result = require('folktale/data/result');
* isDirectory :: String -> Boolean | Error
* Verify if given input is directory
*/
const isDirectory = src => fs.statSync(src).isDirectory();
const isDirectory = (src) => fs.statSync(src).isDirectory();

/**
* getFilesInDirectory :: String -> [String] | Error
* Return all service functions
*/
const getFilesInDirectory = R.ifElse(
isDirectory,
dir => Array.prototype.concat(...fs.readdirSync(dir).map(f => getFilesInDirectory(path.join(dir, f)))),
(dir) => Array.prototype.concat(...fs.readdirSync(dir).map((f) => getFilesInDirectory(path.join(dir, f)))),
R.of
);

const safeGetFilesInDirectory = src => Result.try(() => getFilesInDirectory(src));
const safeGetFilesInDirectory = (src) => Result.try(() => getFilesInDirectory(src));

const safeGetFileContent = src => Result.try(() => fs.readFileSync(src));
const safeGetFileContent = (src) => Result.try(() => fs.readFileSync(src));

module.exports = {
safeGetFileContent,
safeGetFilesInDirectory
safeGetFilesInDirectory,
};
4 changes: 2 additions & 2 deletions lib/service/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const path = require('path');
const R = require('ramda');
const Result = require('folktale/data/result');

const isMarkdown = src => R.contains(path.extname(src), ['.markdown', '.mdown', '.mkdn', '.md', '.mkd', '.mdwn']);
const isMarkdown = (src) => R.contains(path.extname(src), ['.markdown', '.mdown', '.mkdn', '.md', '.mkd', '.mdwn']);

module.exports = {
isMarkdown
isMarkdown,
};
8 changes: 4 additions & 4 deletions lib/service/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const R = require('ramda');
const Result = require('folktale/data/result');

// safeRequire :: String -> Result a Error
const safeRequire = filePath => Result.try(() => require(filePath));
const safeRequire = (filePath) => Result.try(() => require(filePath));

/**
* getLogger :: String -> Object | process.exit
* Get the Barlafus logger given the project directory
*/
const getLogger = projectDir => {
const getLogger = (projectDir) => {
const logger = createBarlafusLogger(projectDir);
if (logger instanceof Error) {
console.log(logger);
Expand All @@ -24,7 +24,7 @@ const getLogger = projectDir => {
* safeRequire :: path -> String -> Result Object Error
* Load settings by joining default and project ones.
*/
const loadSettings = projectDir => {
const loadSettings = (projectDir) => {
const projectSettingsPath = Result.try(() => path.join(projectDir, 'website', 'settings.json'));
const loadProjectSettings = R.chain(safeRequire);
const mergeLift = R.lift(R.merge);
Expand All @@ -37,5 +37,5 @@ const loadSettings = projectDir => {

module.exports = {
getLogger,
loadSettings
loadSettings,
};

0 comments on commit 08b6d67

Please sign in to comment.