V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
爱意满满的作品展示区。
sox

更简单地管理 Node.js 命令行程序里的配置文件

  •  
  •   sox ·
    egoist · Oct 21, 2015 · 1639 views
    This topic created in 3850 days ago, the information mentioned may be changed or developed.

    很多时候一个命令行程序会往 USER_HOME 目录保存一些 config 文件,比如 .gitconfig .zshrc

    所以我造了个轮子 myconf 用来管理这些 config 文件

    很简单的 API:

    import Config from 'myconf'
    
    // This points to a file $USER_HOME/.customconfig
    const config = new Config('.customconfig')
    
    config
      .set('name', 'config for my project')
      .then(data => console.log(data.name))
    
    config
      .get('name')
      .then(name => console.log(name))
    

    一个使用此包的例子: https://github.com/egoist/toka


    GitHub 仓库: https://github.com/egoist/myconf

    NPM 安装: npm i -S myconf

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5172 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 58ms · UTC 01:08 · PVG 09:08 · LAX 18:08 · JFK 21:08
    ♥ Do have faith in what you're doing.