Giter VIP home page Giter VIP logo

find-rc's Introduction

npm install find-rc

Find a rc file given a name. Inspiration from rc.

Build Status

The rc file is assumed to be written in JavaScript, therefore the filename must be .${app}rc.js or .${app}rc.cjs or .${app}rc.mjs . If your app is named 'lab' then the rc file must be named .labrc.js (.labrc.cjs / .labrc.mjs).

Here is the order that folders will be searched:

  1. Current directory
  2. Parent of current directory, until the root folder is encountered
  3. $HOME/.${app}rc.js
  4. $HOME/.${app}rc.cjs
  5. $HOME/.${app}rc.mjs
  6. $HOME/.config/.${app}rc.js
  7. $HOME/.config/.${app}rc.cjs
  8. $HOME/.config/.${app}rc.mjs

(appname, [startDir])

  • appname - name of file you are looking for. Example: lab. It will be formatted as .{appname}rc.js
  • startDir - (optional) directory to start looking for the file. Defaults to process.cwd

Example

const FindRc = require('find-rc');

const filePath = FindRc('lab');
if (filePath) {
  // load file and parse configuration
  const rc = require(filePath);
}

find-rc's People

Contributors

geek avatar dominykas avatar deedf avatar jon-walton avatar

Watchers

 avatar James Cloos avatar  avatar

find-rc's Issues

Broken on Windows

Hey

This is output from running test on Windows, it is affecting lab upgrade for me due to this commit hapijs/lab@4d22872

D:\Modules\find-rc>npm t

> [email protected] pretest D:\Modules\find-rc
> npm run lint


> [email protected] lint D:\Modules\find-rc
> belly-button


Clean as a whistle! No issues found!


> [email protected] test D:\Modules\find-rc
> lab -c


<--- Last few GCs --->

   14567 ms: Mark-sweep 1379.3 (1434.9) -> 1379.2 (1434.9) MB, 248.4 / 0 ms [allocation failure] [GC in old space requested].
   14946 ms: Mark-sweep 1379.2 (1434.9) -> 1379.2 (1434.9) MB, 311.9 / 0 ms [allocation failure] [GC in old space requested].
   15254 ms: Mark-sweep 1379.2 (1434.9) -> 1379.2 (1434.9) MB, 308.0 / 0 ms [last resort gc].
   15563 ms: Mark-sweep 1379.2 (1434.9) -> 1379.2 (1434.9) MB, 308.9 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 000001E8B85C9E79 <JS Object>
    2: normalize [path.js:~308] [pc=000001786FB2BEFE] (this=0000035349DFA5D1 <an Object with map 000003F9F430CBE1>,path=000002238A004101 <String[13]: D:\\.labrc.js>)
    3: join [path.js:~458] [pc=000001786FB44320] (this=0000035349DFA5D1 <an Object with map 000003F9F430CBE1>)
    4: arguments adaptor frame: 2->0
    5: dirPaths [D:\Modules\find-rc\node_modules\find-rc\lib\index.js:~44] [pc=00...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
npm ERR! Test failed.  See above for more details.

Thanks

Support for .cjs (and .mjs?)

Let me keep this short :)

Basically, I'd like to be able to use .labrc.cjs (because I'd like to be able to use "type": "module") in the package.json.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.