I in electron am doing:
path.dirname('C:\\Users\\Blagoh\\Documents\\GitHub\\Screeenshoter\\dist\\electron\\main')
That path is the actual value of my __dirname
. How come it is not giving me C:\\Users\\Blagoh\\Documents\\GitHub\\Screeenshoter\\dist\\electron
? I want that main
part chopped off.
Assuming
main
is adirectory
insideelectron
. Also assuming that you have some file calledindex.js
insidemain
folder where you want to have thepath of electron directory
.So, you can do path.join this way:
Your original file location:
__dirname will return
and then inside path.join '../', will chop off the main folder from path. So, you will be left off with:
Well you obviously didn't read the docs for dirname. It states that it works like the Unix command
dirname
which "strips non-directory suffix from file name", thus you get theC:\\Users\\Blagoh\\Documents\\GitHub\\Screeenshoter\\dist\\electron
.What you are looking for is basename.
path.basename('C:\\Users\\Blagoh\\Documents\\GitHub\\Screeenshoter\\dist\\electron\\main')
will give youmain
.