copyguard
copyguard utilitas sederhana untuk menyalin file dengan aman dan fleksibel
Mendukung operasi penyalinan dasar dan fitur keamanan untuk mencegah penimpaan file yang tidak disengaja.
Instalasi
npm install copyguard
API
copyFileSafely(source: string, destination: string): Promise<void>
Salin file dari lokasi sumber ke tujuan.
source
: Path ke file sumber.destination
: Path tujuan untuk menyalin file.
// ESM
import { copyguard } from 'copyguard'
await copyguard.copyFileSafely('source.txt', 'destination.txt')
// CommonJS
const { copyguard } = require('copyguard')
copyguard.copyFileSafely('source.txt', 'destination.txt')
copyFileWithExcl(source: string, destination: string): Promise<void>
Salin file dengan aman menggunakan constants.COPYFILE_EXCL
.
source
: Path ke file sumber.destination
: Path tujuan untuk menyalin file.
// ESM
import { copyguard } from 'copyguard'
await copyguard.copyFileWithExcl('source.txt', 'destination.txt')
// CommonJS
const { copyguard } = require('copyguard')
copyguard.copyFileWithExcl('source.txt', 'destination.txt')