bower-component-files
v1.0.2
Published
A package to copy/fetch dependency files (js, css, less, etc) from bower dependency packages to a web application directory.
Downloads
5
Readme
bower-component-files
Synopsis
bower-component-files is used to copy/fetch dependency files (js, css, less, etc) from bower dependency packages to a web application directory. Following functions are available.
- bowerComponentFiles.copyMainFiles(filter : Array<String>/Object, options : Object)
The method copies main files that match regular expression, to the corresponding destination.
eg:
bowerComponentFiles.copyMainFiles({"*.js": "./webapp/vendor/{{comp_name}}/js",
"*.css": "./webapp/vendor/{{comp_name}}/css",
"*.less": "./webapp/vendor/{{comp_name}}/less"},
{ exclude: '*boot*.js' });
- bowerComponentFiles.copyComponentFiles(filter : Array<String>/Object, options : Object)
The method copies files from specified directory under specified component/package to the corresponding destination. This method is used to copy files not mentioned as main files in bower.json.
eg:
bowerComponentFiles.copyComponentFiles("moment", {'*.js': './webapp/vendor/{{comp_name}}/js'});
- bowerComponentFiles.getMainFiles(filter : Array<String>, options : Object) : Array<String>
The method fetches main files that match regular expression, which can be fed to gulp to process further.
eg:
gulp.src(bowerComponentFiles.getMainFiles(["*.js", "*.css"],)).pipe( gulp.dest( 'dest/lib'));
- bowerComponentFiles.getComponentFiles(filter : Array<String>, options : Object) : Array<String>
eg:
gulp.src(bowerComponentFiles.getComponentFiles('jquery',
["dist/*.js", "dist/*.css"], {})).pipe(gulp.dest('dest/lib'));
Filter eg:
1. {
"*.js": "./webapp/js",
"*.css": "./webapp/css",
"*.less": "./webapp/less"
// ...
}
2. {
"*.js": "./webapp/vendor/{{comp_name}}/js",
"*.css": "./webapp/vendor/{{comp_name}}/css",
"*.less": "./webapp/vendor/{{comp_name}}/less"
// ...
}
// Note: Currently comp_name & comp_version are supported.
3. ["*.js", "*.css"]
// Note: Default destination is '.' in this case. Every extention would
// create a sub-directory.
// This would be compiled as
{
"*.js": "./js",
"*.css": "./css",
}
Installation
npm install bower-component-files
Usage
var bowerComponentFiles = require('bower-component-files');
bowerComponentFiles.copyMainFiles({ "*.js": "./webapp/js",
"*.css": "./webapp/css",
"*.less": "./webapp/less"
},
{ exclude: '*boot*.js' });
Testing
[sudo] npm test
With test coverage:
[sudo] npm test --coverage
License
The MIT License (MIT)
Copyright (c) 2016 Nikhil Gahlot