Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
grunt-bowercopy
Advanced tools
Wrangle those bower dependencies and place each one where it's supposed to be.
bower_components
directory in your build to make it work. This plugin clears the detritus.Whenever you add a new bower dependency, add which file should be copied and where to your Gruntfile "bowercopy"
config. Then, run grunt bowercopy
.
By default, bowercopy runs bower install
for you (turn this off with the runbower
option). Your bower directory is not removed so you can see which files you need from each component.
It is suggested that you add the bower directory (usually 'bower_components'
) to your .gitignore
.
This plugin requires Grunt.
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-bowercopy --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-bowercopy');
Note: have a look at load-grunt-tasks so you can skip this step for all your grunt plugins.
In your project's Gruntfile, add a section named bowercopy
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
bowercopy: {
options: {
// Task-specific options go here
},
your_target: {
// Target-specific file lists and/or options go here
}
}
});
Type: String
Default value: The directory
property value in your .bowerrc
or 'bower_components'
if the .bowerrc
cannot be found.
srcPrefix
will prefix your source locations with the correct bower folder location.
Type: String
Default value: ''
destPrefix
will be used as the prefix for destinations.
Type: Boolean
Default value: true
Run bower install
in conjunction with the bowercopy
task.
Type: Boolean
Default value: true
Report any modules in your bower.json that have not been configured to copy at least one file with bowercopy
.
Note: The clean option reports the same thing, so this option is ignored if clean is true.
Type: Boolean
Default value: false
Removes the bower components directory on completion. The folder path that is removed is options.srcPrefix
.
Note: the directory will only be removed if the following conditions are met.
grunt bowercopy
and not grunt bowercopy:target
).Type: Array
Default value: []
Using the report
or clean
option, grunt-bowercopy
tracks which dependencies have at least one file copied.
The ignore
option can be used to specify any bower dependencies that aren't copied, but need to be defined in your bower.json
anyway.
Type: Object
Default value: {}
Options to pass to grunt.file.copy
when copying the files. See grunt.file.copy
grunt.initConfig({
bowercopy: {
options: {
// Bower components folder will be removed afterwards
clean: true
},
// Anything can be copied
test: {
options: {
destPrefix: 'test/js'
},
files: {
// Keys are destinations (prefixed with `options.destPrefix`)
// Values are sources (prefixed with `options.srcPrefix`); One source per destination
// e.g. 'bower_components/chai/lib/chai.js' will be copied to 'test/js/libs/chai.js'
'libs/chai.js': 'chai/lib/chai.js',
'mocha/mocha.js': 'libs/mocha/mocha.js',
'mocha/mocha.css': 'libs/mocha/mocha.css'
}
},
// Javascript
libs: {
options: {
destPrefix: 'public/js/libs'
},
files: {
'jquery.js': 'jquery/jquery.js',
'require.js': 'requirejs/require.js'
},
},
plugins: {
options: {
destPrefix: 'public/js/plugins'
},
files: {
// Make dependencies follow your naming conventions
'jquery.chosen.js': 'chosen/public/chosen.js'
}
},
// Less
less: {
options: {
destPrefix: 'less'
},
files: {
// If either the src or the dest is not present,
// the specified location will be used for both.
// In other words, this will copy
// 'bower_components/bootstrap/less/dropdowns.less' to 'less/bootstrap/less/dropdowns.less'
// See http://gruntjs.com/configuring-tasks#files for recommended files formats
src: 'bootstrap/less/dropdowns.less'
}
},
// Images
images: {
options: {
destPrefix: 'public/images'
},
files: {
'account/chosen-sprite.png': 'chosen/public/chosen-sprite.png',
'account/chosen-sprite@2x.png': 'chosen/public/chosen-sprite@2x.png'
}
},
// Entire folders
folders: {
files: {
// Note: when copying folders, the destination (key) will be used as the location for the folder
'public/js/libs/lodash': 'lodash',
// The destination can also be a folder
// Note: if the basename of the location does not have a period('.'),
// it is assumed that you'd like a folder to be created if none exists
// and the source filename will be used
'public/js/libs': 'lodash/dist/lodash.js'
}
},
// Glob patterns
glob: {
files: {
// When using glob patterns, destinations are *always* folder names
// into which matching files will be copied
// Also note that subdirectories are **not** maintained
// if a destination is specified
// For example, one of the files copied here is
// 'lodash/dist/lodash.js' -> 'public/js/libs/lodash/lodash.js'
'public/js/libs/lodash': 'lodash/dist/*.js'
}
},
// Glob without destination
globSrc: {
options: {
destPrefix: 'public/js/libs'
},
// By not specifying a destination, you are denoting
// that the lodash directory structure should be maintained
// when copying.
// For example, one of the files copied here is
// 'lodash/dist/lodash.js' -> 'public/js/libs/lodash/dist/lodash.js'
src: 'lodash/**/*.js'
},
// Main pragma
// Adding :main to the end of a source path will retrieve the main file(s) for that package
// If the main property is not specified by a package, bowercopy will fail
main: {
src: 'jquery.minlight:main',
dest: 'public/js/plugins/'
}
}
});
Follow the same coding style present in the repo and add tests for any bug fix or feature addition.
See the CONTRIBUTING.md for more info.
ignore
option.options.report
. Camelcase options.runBower
. Fix an issue with a source format (gh-9).options.copyOptions
to be passed along to grunt.file.copy
and fix issue with local-only bower usage.Copyright (c) 2014 Timmy Willison. Licensed under the MIT license.
FAQs
Scrupulously manage file locations for bower dependencies.
We found that grunt-bowercopy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.