Skip to content

Instantly share code, notes, and snippets.

@EtienneR
Created March 16, 2016 13:55
Show Gist options
  • Save EtienneR/de9abe47e260baea9823 to your computer and use it in GitHub Desktop.
Save EtienneR/de9abe47e260baea9823 to your computer and use it in GitHub Desktop.
Get the current folder with NodeJS
const os = require('os');
if (os.platform() == 'win32') {
// Windows
var path_folder = __dirname.split("\\");
} else {
// Linux / MacOS
var path_folder = __dirname.split("/");
}
var length = path_folder.length;
var current_folder = path_folder[length - parseInt(1)];
// Display the current folder name
console.log(current_folder);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment