After the shebang I am requiring in two other scripts that I have thrown together that have to do with the general process of what I want my initialization command to do. The first thing to come to mind is to check that a target folder is exists, and if so if it is empty, for this there is the check target module. Once that check works out okay, I then want another module that is used to create a starting point for a new project, for this there is the create project module.
Once the two modules are loaded the script just checks the target folder that is given which by default is the current working directory. If the check works out okay the create project method is then used for the target directory. The basic idea that I have in mind for an initialization command is more or less this, but if the project grows I might want to add additional features.
Here is the source code of the check target module. Here I am using the built in nodejs file system module, along with the promisify method of the built in util module, to make sure that the stat and readdir methods return promises in older versions of node.
Here I have the source code of the create project module. For now the command just creates a _posts folder and places a demo post in the folder that is stored in the init folder of this project. If I do continue working on this project it will likely do a great deal more but for now that is it.
That is it for not on my nc-init command for ny node cli tools project, I am still working on this one and might keep doing so for a while until I have something better to do. So In the future I might get around to editing this post as I keep working on it and have the init command do more.