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:
const packageRoot = require('firost/packageRoot');
const readJson = require('firost/readJson');
const path = require('path');
(async () => {
const { version } = await readJson(
path.resolve(packageRoot(), 'package.json')
);
})()
const readJsonUrl = require('firost/readJsonUrl');
const write = require('firost/write');
(async () => {
const url =
"https://raw.githubusercontent.com/pixelastic/firost/master/package.json";
const data = await readJsonUrl(url);
await write(data.description, './description.txt');
})();
const copy = require('firost/copy');
(async () => {
await copy('./src/**/*.css', './dist');
})();
The complete documentation can be found on https://projects.pixelastic.com/firost/