
This alias gives us the same function but with an all-lowercase name. finally there is one more alias: mkdirP.mkdirp = mkdirP.mkdirP = mkdirP.Maybe someone would prefer the second form for being more explicit. For example, the alias means we can get the same function in 2 different ways: Why would we do this? I can’t speak for the author’s intention here, but it could be to allow different forms of require. This new property is an alias back to the original function. The shell does not have a trash bin: once something is deleted, it’s really gone. Use of the Control key may be described in many ways, including Ctrl-X, Control-X, and X. module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP: what we’re doing here is adding a new property to the mkdirP function (remember that in javascript functions are objects). mv old new moves (renames) a file or directory.module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP is the main function that we’re exporting.The first thing that stands out here is on line 4: module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP Īt first glance it looks a bit odd, but it’s quite easy to understand if we read it from right to left: If we look in index.js we’re dealing with just under 100 lines. If you’re like me, you’ve probably used this library many more times than you actually realize – it is a dependency of about 1000 other modules in npm! So understanding modules like this will naturally lead us on to enlightenment elsewhere.

Get ready to dig into substack’s excellent mkdirp, a handy library for recursively creating directories (just like mkdir -p in linux). If you are in the documents folder on your hard drive and you write. If this all goes to plan we’ll come away not only understanding the internal workings of a commonly-used module, we’ll also discover some interesting patterns and techniques along the way. The mkdir command creates a folder in the address you specify or in the folder you are in. But mkdir -p command will create it at once.Greetings adventurer! In today’s expedition we’re going to pick a popular nodejs library and dive into its depths to see what we can find. With mkdir command you have to ceate every file one by one. Hence this command is very useful to create a long file like "office/client/raj/date". As directory 'envelope' doesn't exists, it will first create 'envelope' and then its sub-directory 'letter' without printing any error. Now in the later part of the image if you'll see, I have created a directory 'envelope' with its sub-directory 'letter'. mkdir command in Linux allows the user to create directories (also referred to as folders in some operating systems ). Hence, without showing an error it will create 'docu'. As you know, we already have directory 'created'. For instance, in the above screenshot I wanted to create a 'docu' in 'created'. This command is most helpful in the case when you don't know whether a directory alredy exists or not. Most likely the line where the path is defined is meant to be adapted as required. , so the current working directory, does not change this. The fact that this makes little sense when the path is specified as. But if it already exists, then it will not print an error message and will move further to create sub-directories. mkdir -p means: create the directory and, if required, all parent directories. It will create parent directory first, if it doesn't exist.

With the help of mkdir -p command you can create sub-directories of a directory.
