Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function errorHandler(error) {
throw error;
}
var Do = require('do');
// Convert `readFile` from fs to use continuable style.
var fs = Do.convert(require('fs'), ['readFile']);
function safeRead(filename) { return function (callback, errback) {
fs.readFile(filename)(callback, function (error) {
if (error.errno === process.ENOENT) {
callback("");
} else {
errback(error);
}
})
}}
safeRead(__filename)(console.log, errorHandler);
// Load some libraries
require.paths.unshift(__dirname + "/vendor");
var Haml = require('haml'),
Markdown = require('markdown'),
md5 = require('md5').md5,
Do = require('do'),
fs = Do.convert(require('fs'), ['readdir', 'stat', 'readFile', 'writeFile']),
sys = Do.convert(require('sys'), ['exec']);
var ARTICLE_DIR = __dirname + '/data/articles',
AUTHOR_DIR = __dirname + '/data/authors',
SKIN_DIR = __dirname + '/data/skin',
PUBLIC_DIR = __dirname + '/public';
var Filters = {
// Extends markdown by allowing properties at the top.
markdown: function (markdown) {
var match;
var props = {};
while(match = markdown.match(/^([a-z]+):\s*(.*)\s*\n/i)) {
var name = match[1].toLowerCase(),
value = match[2];
// Load some libraries
require.paths.unshift(__dirname + "/vendor");
var Haml = require('haml'),
Markdown = require('markdown'),
md5 = require('md5').md5,
Do = require('do'),
fs = Do.convert(require('fs'), ['readdir', 'stat', 'readFile', 'writeFile']),
sys = Do.convert(require('sys'), ['exec']);
var ARTICLE_DIR = __dirname + '/data/articles',
AUTHOR_DIR = __dirname + '/data/authors',
SKIN_DIR = __dirname + '/data/skin',
PUBLIC_DIR = __dirname + '/public';
var Filters = {
// Extends markdown by allowing properties at the top.
markdown: function (markdown) {
var match;
var props = {};
while(match = markdown.match(/^([a-z]+):\s*(.*)\s*\n/i)) {
var name = match[1].toLowerCase(),
value = match[2];
markdown = markdown.substr(match[0].length);
function errorHandler(error) {
throw error;
}
var Do = require('do');
var fs = Do.convert(require('fs'), ['readdir', 'stat', 'readFile']);
// Checks the `stat` of a file path and outputs the file contents if it's
// a real file
function loadFile(path, callback, errback) {
fs.stat(path)(function (stat) {
// Output undefined when the path isn't a regular file
if (!stat.isFile()) {
callback();
return;
}
// Pass through the read to regular files as is.
fs.readFile(path, 'utf8')(callback, errback)
}, errback);