
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
grunt-contrib-copy
Advanced tools
The grunt-contrib-copy package is a Grunt plugin that provides file copying capabilities. It allows you to copy files and directories from one location to another, which is useful for tasks such as preparing files for deployment, creating backups, or organizing project files.
Copying individual files
This feature allows you to copy a single file from a source location to a destination location. In this example, 'src/file1.txt' is copied to 'dest/file1.txt'.
{
"copy": {
"main": {
"src": "src/file1.txt",
"dest": "dest/file1.txt"
}
}
}
Copying multiple files
This feature allows you to copy multiple files by specifying an array of source and destination file paths. In this example, 'src/file1.txt' and 'src/file2.txt' are copied to 'dest/file1.txt' and 'dest/file2.txt' respectively.
{
"copy": {
"main": {
"files": [
{"src": "src/file1.txt", "dest": "dest/file1.txt"},
{"src": "src/file2.txt", "dest": "dest/file2.txt"}
]
}
}
}
Copying entire directories
This feature allows you to copy entire directories, including all subdirectories and files. The 'expand' option is set to true to enable dynamic building of the destination paths. The 'cwd' option specifies the current working directory, and 'src' specifies the pattern to match files. In this example, all files and directories under 'src/' are copied to 'dest/'.
{
"copy": {
"main": {
"expand": true,
"cwd": "src/",
"src": ["**"],
"dest": "dest/"
}
}
}
Flattening directory structure
This feature allows you to flatten the directory structure when copying files. The 'flatten' option is set to true, which means all files will be copied directly into the destination directory without preserving the directory structure. In this example, all files under 'src/' are copied directly into 'dest/'.
{
"copy": {
"main": {
"expand": true,
"cwd": "src/",
"src": ["**"],
"dest": "dest/",
"flatten": true
}
}
}
gulp-copy is a Gulp plugin that provides similar file copying capabilities as grunt-contrib-copy. It allows you to copy files and directories using Gulp tasks. Compared to grunt-contrib-copy, gulp-copy is used within the Gulp task runner ecosystem, which may be preferred by developers who use Gulp for their build processes.
cpx is a command-line tool and library for copying files and directories. It supports advanced features such as watching for changes and copying only modified files. Compared to grunt-contrib-copy, cpx can be used both as a standalone CLI tool and as a library within Node.js scripts, providing more flexibility in different environments.
ncp (Node Copy) is a Node.js module for copying files and directories. It provides a simple API for recursive copying and supports various options for filtering and transforming files during the copy process. Compared to grunt-contrib-copy, ncp is a lower-level library that can be used directly in Node.js scripts without relying on a task runner like Grunt.
Copy files and folders.
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, install this plugin with this command:
npm install grunt-contrib-copy --save-dev
Run this task with the grunt copy
command.
This task is a [multi task][] so any targets, files and options should be specified according to the [multi task][] documentation. [multi task]: https://github.com/gruntjs/grunt/wiki/Configuring-tasks
Version 0.4.x
of this plugin is compatible with Grunt 0.4.x
. Version 0.3.x
of this plugin is compatible with Grunt 0.3.x
.
Type: Function
This option is passed to grunt.file.copy
as an advanced way to control the file contents that are copied.
Type: String
This option is passed to grunt.file.copy
as an advanced way to control which file contents are processed.
copy: {
main: {
files: [
{src: ['path/*'], dest: 'dest/', filter: 'isFile'}, // includes files in path
{src: ['path/**'], dest: 'dest/'}, // includes files in path and its subdirs
{expand: true, cwd: 'path/', src: ['**'], dest: 'dest/'}, // makes all src relative to cwd
{expand: true, flatten: true, src: ['path/**'], dest: 'dest/', filter: 'isFile'} // flattens results to a single level
]
}
}
Task submitted by Chris Talkington
This file was generated on Wed Jan 23 2013 10:40:27.
FAQs
Copy files and folders
The npm package grunt-contrib-copy receives a total of 246,368 weekly downloads. As such, grunt-contrib-copy popularity was classified as popular.
We found that grunt-contrib-copy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers 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.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.