Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElectronJS - adding folder to favorites [macOS]

I am wondering if there is a way to add a folder to Favorites using Node?

I've found this issue, but the solution does not work anymore.

Basically the file that I'm interested in is located in:

/Users/USER_NAME/Library/Application\ Support/com.apple.sharedfilelist

The thing is I do not know how to modify it...

like image 210
mdmb Avatar asked Jul 25 '18 22:07

mdmb


1 Answers

You can use try os module. Very easy to use. Here is an example:

const home = require("os").homedir(); // This will get your OS based Home directory
const dirToSave = `${home}/Desktop/output.csv`; // Now you can add file or folder to any tree directory of home directory.
fs.writeFile(`${dirToSave}`, {csvData}, function(err, stat) {
   if (err) throw err;
   console.log("file saved");
});
like image 138
Naimur Rahman Avatar answered Oct 16 '22 19:10

Naimur Rahman