1.1.0 • Published 3 years ago

@wethegit/sweet-potato-utensils v1.1.0

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

sweet-potato-utensils 🥣

Shared utility functions and variables used across the sweet-potato packages.

Usage

npm install @wethegit/sweet-potato-utensils

config

Contains all the common paths and most importantly the user's options.

const { config } = require("@wethegit/sweet-potato-utensils");

// get projects builld directory
config.OPTIONS.buildDirectory;

getFiles

Small wrapper around the glob package to promisify it.

const { getFiles, config } = require("@wethegit/sweet-potato-utensils");

async function getAllJPGsOnProject() {
  const jpgs = await getFiles(
    path.join(config.PUBLIC_DIRECTORY, "**", "*.jpg")
  );
  // do something with jpgs
}

logger

Function that helps standardize all the logs across all packages.

const { logger } = require("@wethegit/sweet-potato-utensils");

// Simple string
logger.announce("Config parsed");

// You can also pass a second argument for .error
// The logger will try its best to display the propper error message
logger.error("Couldn't compile", error);

// Pass in an array and logger will concat messages with an arrow ->
// The result of this call will be
// SUCCESS:: File saved with success -> /build/file.html
logger.success(["File saved with success", file]);

// other types of messages
logger.warning("Deprecated on next version");
logger.start("Stated compiling pages");
logger.finish("Finished compiling pages");