Today I Learned - Rocky Kev

TIL getting all files with an extension in Node using Glob

POSTED ON:

TAGS:

I wanted to find all json files within a folder structure.

npm i glob

const glob = require('glob');

function getFilesFromPath(path, extension) {
return glob.sync(`${path}/**/*.${extension}`);
}

// get me all .gz files inside the aws directory
const allZippedFiles = getFilesFromPath('./cheerio_data/aws/', "gz");

// get me all the scss files inside the source directory
const allScssFiles = getFilesFromPath('./src/', "scss");

Resources:


Related TILs

Tagged:

TIL what is npm Script

Despite their high usage they are not particularly well optimized and add about 400ms of overhead. In this article we were able to bring that down to ~22ms.

TIL keywords in package.json

Today I learned what keywords are in a package.json file! It's a collection of keywords about a module. Keywords can help identify a package, related modules and software, and concepts.

TIL functional async/await

PLACEHOLDER