You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
599 B
JavaScript
20 lines
599 B
JavaScript
'use strict';
|
|
|
|
const Promise = require("bluebird");
|
|
const fs = Promise.promisifyAll(require("fs"));
|
|
const path = require("path");
|
|
const util = require("util");
|
|
|
|
const parseRecipes = require("./src/parse/recipes");
|
|
|
|
Promise.try(() => {
|
|
return fs.readdirAsync(process.argv[2]);
|
|
}).map((file) => {
|
|
return fs.readFileAsync(path.join(process.argv[2], file));
|
|
}).map((fileContents) => {
|
|
return parseRecipes(fileContents.toString());
|
|
}).reduce((allRecipes, recipes) => {
|
|
return allRecipes.concat(recipes);
|
|
}, []).then((results) => {
|
|
console.log(util.inspect(results, {depth: null, colors: true}));
|
|
}); |