Negligible Psychological Misery


Need private packages and team management tools?Check out npm Orgs. »


1.3.1 • Public • Published


npm version


africa is a Node.JS package which simplifies reading from and writing to persistent configuration files in user's home directory. If a configuration exists, it will be read, and if not, the user will be presented with questions, after which the answers will be stored in the .rc file.

yarn add africa

Table Of Contents


The package is available by importing its default function:

import africa from 'africa'

async africa(
  packageName: string,
  questions: object,
  config?: {
    force?: boolean,
    homedir?: string,
    questionsTimeout?: number,
    local?: boolean,
    rcNameFunction?: function,
): Object

Call africa asynchronously to read or create a new configuration. Questions should adhere to the reloquent's interface.

Argument Description
packageName Name of the package which uses africa. It will be used when generating a name for the .rc file.
questions An object with questions answers to which will be saved into the .rc file.
config Additional configuration parameters, see AfricaConfig Type.
import africa from 'africa'
import { userInfo } from 'os'
(async () => {
  try {
    const config = await africa('africa', {
      name: {
        defaultValue: userInfo().username,
        text: 'user',
    }, { force: true })
  } catch ({ stack }) {
user: [zavr]
{ name: 'zavr' }

_africa.Config: The configuration object to configure additional functionality.

Name Type & Description Default
force boolean false
Ask questions and update the configuration file even if it already exists.
homedir string os.homedir()
In which directory to save and search for configuration file.
questionsTimeout number -
How log to wait in ms before timing out. Will wait forever by default.
local boolean false
Whether to read a local config file in the current working directory rather than in the HOMEDIR. When initialising, the default values will be taken from the home config if it exists so that it is easy to extend .rc files.
rcNameFunction function(string): string -
Function used to generate the .rc name. Default: packageName => .${packageName}rc.

Photo Diana Robinson, 2017

Art Deco © Art Deco 2019 Tech Nation Visa Tech Nation Visa Sucks


npm i africa

Downloadsweekly downloads









last publish


  • avatar
Report a vulnerability