ledgerrb/public/vendor/node_modules/normalize-config
Gwenhael Le Moine 8e15ce78ba
'backported' client from credger
Signed-off-by: Gwenhael Le Moine <gwenhael.le.moine@gmail.com>
2019-12-13 15:13:43 +01:00
..
lib 'backported' client from credger 2019-12-13 15:13:43 +01:00
node_modules/kind-of 'backported' client from credger 2019-12-13 15:13:43 +01:00
index.js 'backported' client from credger 2019-12-13 15:13:43 +01:00
LICENSE 'backported' client from credger 2019-12-13 15:13:43 +01:00
package.json 'backported' client from credger 2019-12-13 15:13:43 +01:00
readme.md 'backported' client from credger 2019-12-13 15:13:43 +01:00

normalize-config NPM version

Normalize a declarative configuration with any combination of src-dest mappings, files arrays, files objects and options into a consistent format so the config can easily be passed to any build system.

Install

Install with npm:

$ npm i normalize-config --save

Usage

var config = require('normalize-config');

All of the following normalize to the same object:

config('*.js', 'dist/')
//=> { files: [ { src: [ '*.js' ], dest: 'dist/' } ] }
config(['*.js'], 'dist/')
//=> { files: [ { src: [ '*.js' ], dest: 'dist/' } ] }
config({'dist/': '*.js'})
//=> { files: [ { src: [ '*.js' ], dest: 'dist/' } ] }
config({'dist/': ['*.js']})
//=> { files: [ { src: [ '*.js' ], dest: 'dist/' } ] }
config({src: '*.js', dest: 'dist/'})
//=> { files: [ { src: [ '*.js' ], dest: 'dist/' } ] }
config({src: ['*.js'], dest: 'dist/'})
//=> { files: [ { src: [ '*.js' ], dest: 'dist/' } ] }
config({files: {'dist/': '*.js'}})
//=> { files: [ { src: [ '*.js' ], dest: 'dist/' } ] }
config({files: {'dist/': ['*.js']}})
//=> { files: [ { src: [ '*.js' ], dest: 'dist/' } ] }
config({files: [{'dist/': ['*.js']}]})
//=> { files: [ { src: [ '*.js' ], dest: 'dist/' } ] }

Examples

All of the following:

// src | dest | options
config('*.js', 'dist/', {cwd: 'lib'});

// {src, dest, options}
config({src: '*.js', dest: 'dist/', options: {cwd: 'lib'}});

// {src, dest} | options
config({src: '*.js', dest: 'dist/'}, {cwd: 'lib'});

result in:

{ 
  options: { cwd: 'lib' },
  files: [ 
    { options: { cwd: 'lib' }, 
      src: [ '*.js' ], 
      dest: 'dist/' 
    } 
  ]
}

All of the following result in the same object:

config('lib/*.js', 'foo/');
config({'foo/': 'lib/*.js'});
config({dest: 'foo/', src: 'lib/*.js'});
//=> { files: [{ src: [ 'lib/*.js' ], dest: 'foo/' }]}

no dest

All of the following result in the same object:

config('lib/*.js');
config(['lib/*.js']);
config({'': 'lib/*.js'});
config({'': ['lib/*.js']});
config({src: 'lib/*.js'});
config({src: ['lib/*.js']});
config({src: 'lib/*.js', dest: ''});
config({src: ['lib/*.js'], dest: ''});
//=> {files: [{ src: ['lib/*.js'], dest: ''}]}

with dest

All of the following result in the same object:

config('lib/*.js', 'foo/');
config(['lib/*.js'], 'foo/');
config({'foo/': 'lib/*.js'});
config({'foo/': ['lib/*.js']});
config({src: ['lib/*.js'], dest: 'foo/'});
config({src: 'lib/*.js', dest: 'foo/'});
//=> {files: [{ src: ['lib/*.js'], dest: 'foo/'}]}

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

License

Copyright © 2016 Jon Schlinkert Released under the MIT license.


This file was generated by verb on January 05, 2016.