Created
September 8, 2022 18:58
-
-
Save sabesansathananthan/816db9daef602f136bd44092ff0d6279 to your computer and use it in GitHub Desktop.
How to copy files and folders in Node.js?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { exec, spawn } = require('child_process'); | |
exec('cp ./component/data.txt ./page/info.txt'); // When copying files, you need to make sure the target directory exists | |
exec('cp -r ./component ./page/landing/home'); // Copy the folder, the target directory can be created automatically | |
spawn('cp', ['-r', './component', './page/landing/home']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment