UNPKG

@sammwy/milkshake

Version:

<p align="center"> <img src="https://raw.githubusercontent.com/sammwyy/milkshake/master/docs/milkshake.png" height="64px"> <h1 align="center">MilkShake</h1> <p align="center"> <b>Automatize Tasks, Compile, concatenate and minify automaticall

27 lines (23 loc) 785 B
const fs = require("fs"); const path = require("path"); exports.concat = (directory) => { return new Promise ( (resolve, reject) => { fs.readdir(directory, function (err, files) { if (err) { return console.log('Unable to scan directory: ' + err); } let count = 0; let body = []; for (let file of files) { fs.readFile(path.join(directory, file), (err, buffer) => { let content = buffer.toString(); body.push(content); count++; if (count == files.length) { resolve(body); } }) } }); }); }