No Packages Misplaced

    prhone-scp

    0.1.4 • Public • Published

    PRHONE SCP

    npm version Build Status

    Simple config parser.

    Parse simple config files to extract configurable information for your projects.

    Install

    npm install --save prhone-scp

    Example

    __dirname + '/data/config.conf'

    # Config file.
    # Comments start with "#".
     
    USER romel
     
    PASS 123
     
    NAMES
    maria
    john
    karen
     
    ADDRESS
    Street 987 ave 456

    __dirname + '/app.js'

    var scp = require('prhone-scp');
     
    // I recommend token names to be uppercase.
    scp.config({
      //encoding: 'utf8',
      tokens: {
        USER: 'line',
        PASS: 'line',
        NAMES: 'multiline',
        ADDRESS: function (data) {
          data = data.toUpperCase();
          return data;
        }
      }
    });
     
    scp.parse(__dirname +'/data/config.conf', function (err, conf) {
      if (err) throw err;
     
      console.log(conf.USER);  // 'romel'
      console.log(conf.PASS);  // '123'
      console.log(conf.NAMES);  // ['natalia', 'john', 'karen']
      console.log(conf.ADDRESS);  // 'STREET 987 AVE 456'
    });

    License

    MIT

    Install

    npm i prhone-scp

    DownloadsWeekly Downloads

    1

    Version

    0.1.4

    License

    MIT

    Last publish

    Collaborators

    • romelperez