Download uncommitted changes
You can create the zipFiles.js script file in your project directory where you want to manage your zip files. Given your previous commands, it seems you are working in the following directory:
makefile
Copy code
D:\Md. Anisur Rahaman\empower\ESAP_Frontend_Base
Steps to Create the zipFiles.js File:
Navigate to Your Project Directory: Make sure you are in the D:\Md. Anisur Rahaman\empower\ESAP_Frontend_Base directory.
Create the zipFiles.js File: You can create the file using a text editor of your choice. Here are a few methods:
Using Notepad:
Open Notepad (or any text editor).
Copy and paste the provided script into it.
Save the file as zipFiles.js in the D:\Md. Anisur Rahaman\empower\ESAP_Frontend_Base directory.
Using Visual Studio Code (if installed):
Open Visual Studio Code.
Navigate to your project directory (D:\Md. Anisur Rahaman\empower\ESAP_Frontend_Base).
Create a new file and name it zipFiles.js.
Paste the script into the file and save it.
Using Command Line: If you prefer command line, you can use echo to create the file, but it's easier to edit it directly in a text editor:
bash
Copy code
echo // your script here > zipFiles.js
Example Script to Paste
Here’s the script you can use in your zipFiles.js file:
javascript
Copy code
const fs = require('fs');
const archiver = require('archiver');
const output = fs.createWriteStream('uncommitted-changes.zip');
const archive = archiver('zip', {
zlib: { level: 9 }
});
output.on('close', function() {
console.log(archive.pointer() + ' total bytes');
console.log('Zip file has been created successfully.');
});
archive.on('error', function(err) {
throw err;
});
archive.pipe(output);
const exec = require('child_process').exec;
exec('git diff --name-only', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
const files = stdout.split('\n').filter(file => file);
files.forEach(file => {
archive.file(file, { name: file });
});
archive.finalize();
});
Running the Script
After you’ve created the file, you can run it using Node.js:
Open a command prompt or terminal.
Navigate to the project directory:
bash
Copy code
cd "D:\Md. Anisur Rahaman\empower\ESAP_Frontend_Base"
Run the script:
bash
Copy code
node zipFiles.js
This will create a zip file named uncommitted-changes.zip in your project directory, containing the uncommitted files. Let me know if you need any further assistance!
0 comments:
Post a Comment