When writing command-line tools in JavaScript, you end up doing the same common tasks over and over again: reading and writing files, running binary commands, querying JSON APIs, etc. Firost contains higher-level functions to make this work easier and less error-prone.


yarn add firost
// or npm install firost


You can require the whole of firost and use its methods, or require each method individually.

// Require everything
const firost = require('firost');

// Cherry-pick what to require
const glob = require('firost/glob');
const copy = require('firost/copy');


Below are a few examples of the tasks firost can help you with:

Getting the current version of the package you're working on

const packageRoot = require('firost/packageRoot');
const readJson = require('firost/readJson');
const path = require('path');

(async () => {
  const { version } = await readJson(
    path.resolve(packageRoot(), 'package.json')

Read a remote JSON and write part of it on disk

const readJsonUrl = require('firost/readJsonUrl');
const write = require('firost/write');

(async () => {
  const url = 
  const data = await readJsonUrl(url);

  await write(data.description, './description.txt');

Copy all .css files from ./src to ./dist

const copy = require('firost/copy');

(async () => {
  await copy('./src/**/*.css', './dist');