Optionally creating a directory path based based on existence in NodeJS I've been doing some reading and tutorials. As such I've contrived a node based project to apply what I've learned. I thought this was a good example as it had some conditional async calls and error handling.

Any and all criticism of not following current JS best practices welcome. 

/**
 * mkLocalCfg function, 
 * makes a local config directory structure and empty config file.
 * in the form "~/.config/nobjs/nobjs_config.json"
 * 
 * @param {mkLocalCfgCallback} cb - The callback that handles the response.
 * 
 */
function mkLocalCfg(cb) {
    //validate root folder exists, if not make it.
    if (!admin.hasHomeConfigDir()) {
        fs.mkdir(os.homedir() + "/.config", "775", function(err) {
            //stop here if you can't make it.
            if (err) {cb(err); return;}
        });
    }
    fs.mkdir(admin.getConfigLocation(false), "775", function(err) {
        //can't make config folder end it here
        if (err) {cb(err); return;}
        //write config file, return null or err on error
        fs.writeFile(admin.getConfigLocation(true), JSON.stringify({blogs: {}}), function(err) {
            if (err) {cb(err); return;}
            cb(null);
        });
    });
}
There's one main issue I currently see with your code and that is that if the admin does not have a home configuration directory (admin.hasHomeConfigDir()) then it will be created asynchronously. The issue with this it that your second call won't wait for this, leading to a race condition where you're trying to make (and write to) a path that might not exist yet.

One solution for this is to have a function inside your function that handles the "second half" of your creation (i.e. the config location creation and file writing).

function createConfiguration(callback) {

    // Make the configuration directory and write to the configuration.
    var writeConfiguration = function() {
        fs.mkdir(admin.getConfigLocation(false), "775", function(err) {
            if (err) {
                callback(err);
                return;
            }

            // Write the configuration, either forwarding an error to the
            // callback if an error occurs or nothing at all on success.
            fs.writeFile(admin.getConfigLocation(true), JSON.stringify({blogs: {}}), function(err) {
                if (err) {
                    callback(err);
                    return;
                }

                callback(null);
            });
        });
    };

    // If the admin home configuration directory exists, don't attempt to
    // create it.
    if (admin.hasHomeConfigDir()) {
        writeConfiguration();
    } else {
        // Otherwise create the directory and write the configuration.
        fs.mkdir(os.homedir() + "/.config", "775", function(err) {
            if (err) {
                callback(err);
                return;
            }

            writeConfiguration();
        });
    }
}


I tidied up your code a bit, mostly renaming things (e.g. renaming the function to have a simpler name, renaming arguments to be more readable) and rewording the comments.

Another issue I have noticed with your code is that if the directory that admin.getConfigLocation(false) returns already exists, an error will be thrown. You should probably check whether or not the configuration location exists before creating it.

Overall it's rather good and well written code, although I don't really have much experience in the field of "JS standards" so to speak.