How to check if directory exists using Yeoman?


I am asking the user for a directory name, and then if the directory exists I want to ask them if they want to archive it. However I am not sure what function I can use inside Yeoman to achieve this. Here is my code.

prompting: function () {
    return this.prompt([{
        type: 'input',
        name: 'project_directory',
        message: 'What is the project directory name?'
    }, {
        type: 'confirm',
        name: 'archive',
        message: 'That project already exists. Do you want to archive it?',
        when: function (answers) {
            var destDir = 'project/' + answers.project_directory.replace(/[^0-9a-zA-Z\-.]/g, "").toLowerCase();
            var fso = new ActiveXObject("Scripting.FileSystemObject");

            //Return true if the folder exists
            return (fso.FolderExists(destDir));
    }]).then(function (answers) {



Yeoman doesn't provide any built-in methods to verify if a file or a directory exists.

But Yeoman is just Node.js, it's just JavaScript.

So you actually want to ask how to detect if a directory exist with Node.

The type of e1 is Event the type of e2 is *Event. The initialization is actually the same (using composite literal syntax, also not sure if that jargon is Go or C# or both?) but with e2 you using the 'address of operator' & so it returns a pointer to that object rather than the instance itself.

Subtract the julian day integer of the earlier date from the julian integer of the later date. The following tells you exactly how to do that.

Otherwise, already has a C version

long gregorian_calendar_to_jd(int y, int m, int d)
    if(m<3) { y--; m+=12; }
    return (y*365) +(y/4) -(y/100) +(y/400) -1200820

This video can help you solving your question :)
By: admin