Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cp-file

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cp-file

Copy a file

  • 11.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is cp-file?

The cp-file npm package is a utility for copying files with support for progress reporting and other advanced features. It is designed to be a simple and efficient way to copy files in Node.js applications.

What are cp-file's main functionalities?

Basic File Copy

This feature allows you to copy a file from a source path to a destination path. The promise resolves when the file has been successfully copied.

const cpFile = require('cp-file');

cpFile('source.txt', 'destination.txt').then(() => {
  console.log('File copied');
});

Progress Reporting

This feature provides progress reporting during the file copy process. You can listen to the 'progress' event to get updates on the copy progress.

const cpFile = require('cp-file');

cpFile('source.txt', 'destination.txt').on('progress', data => {
  console.log(`Progress: ${data.percent * 100}%`);
}).then(() => {
  console.log('File copied');
});

Preserve Timestamps

This feature allows you to preserve the original file timestamps when copying a file. This can be useful for maintaining file metadata.

const cpFile = require('cp-file');

cpFile('source.txt', 'destination.txt', { preserveTimestamps: true }).then(() => {
  console.log('File copied with timestamps preserved');
});

Overwrite Option

This feature allows you to specify whether to overwrite the destination file if it already exists. By setting the 'overwrite' option to false, you can prevent accidental overwrites.

const cpFile = require('cp-file');

cpFile('source.txt', 'destination.txt', { overwrite: false }).then(() => {
  console.log('File copied without overwriting existing files');
}).catch(error => {
  console.error('File already exists');
});

Other packages similar to cp-file

Keywords

FAQs

Package last updated on 05 Nov 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc