Socket
Book a DemoInstallSign in
Socket

normalize-config

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normalize-config

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.

Source
npmnpm
Version
0.4.2
Version published
Weekly downloads
73
-17.98%
Maintainers
2
Weekly downloads
 
Created
Source

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/'}]}
  • expand-config: Expand tasks, targets and files in a declarative configuration. | homepage
  • expand-files: Expand glob patterns in a declarative configuration into src-dest mappings. | homepage
  • expand-target: Expand target definitions in a declarative configuration. | homepage
  • expand-task: Expand and normalize task definitions in a declarative configuration. | homepage

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 © 2015 Jon Schlinkert Released under the MIT license.

This file was generated by verb-cli on October 31, 2015.

Keywords

config

FAQs

Package last updated on 31 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts