bin/commands/old/add-id.js
function (filename) {
    if (!fs.existsSync(filename)) {
        logger.error({
            method: "edit_add_cookbook_ids",
            filename: filename
        }, "file does not exist");
        return;
    }

    var encoding = 'utf8';
    var changed = false;
    var contents = fs.readFileSync(filename, encoding);
    var _replacer = function (full, cookbook_name) {
        changed = true;
        return util.format('homestar.cookbook(%s, "%s");', cookbook_name, uuid.v4());
    };

    contents = contents.replace(/^\s*homestar\s*.\s*cookbook\s*[(]\s*("[^"]*")\s*[)](\s*;)?/mg, _replacer);
    contents = contents.replace(/^\s*homestar\s*.\s*cookbook\s*[(]\s*('[^"]*')\s*[)](\s*;)?/mg, _replacer);

    if (changed) {
        fs.writeFileSync(filename, contents, {
            encoding: encoding
        });
        logger.info({
            method: "edit_add_cookbook_ids",
            filename: filename
        }, "updated recipe");
    }
}
function (filename) {
    if (!fs.existsSync(filename)) {
        logger.error({
            method: "edit_add_cookbook_ids",
            filename: filename
        }, "file does not exist");
        return;
    }

    var encoding = 'utf8';
    var changed = false;
    var contents = fs.readFileSync(filename, encoding);
    var _replacer = function (full, cookbook_name) {
        changed = true;
        return util.format('homestar.cookbook(%s, "%s");', cookbook_name, uuid.v4());
    };

    contents = contents.replace(/^\s*homestar\s*.\s*cookbook\s*[(]\s*("[^"]*")\s*[)](\s*;)?/mg, _replacer);
    contents = contents.replace(/^\s*homestar\s*.\s*cookbook\s*[(]\s*('[^"]*')\s*[)](\s*;)?/mg, _replacer);

    if (changed) {
        fs.writeFileSync(filename, contents, {
            encoding: encoding
        });
        logger.info({
            method: "edit_add_cookbook_ids",
            filename: filename
        }, "updated recipe");
    }
}
function ( filename ) { if ( ! fs . existsSync ( filename ) ) { logger . error ( { method : "edit_add_cookbook_ids" , filename : filename } , "file does not exist" ) ; return ; } var encoding = 'utf8' ; var changed = false ; var contents = fs . readFileSync ( filename , encoding ) ; var _replacer = function ( full , cookbook_name ) { changed = true ; return util . format ( 'homestar.cookbook(%s, "%s");' , cookbook_name , uuid . v4 ( ) ) ; } ; contents = contents . replace ( / ^\s*homestar\s*.\s*cookbook\s*[(]\s*("[^"]*")\s*[)](\s*;)? / mg , _replacer ) ; contents = contents . replace ( / ^\s*homestar\s*.\s*cookbook\s*[(]\s*('[^"]*')\s*[)](\s*;)? / mg , _replacer ) ; if ( changed ) { fs . writeFileSync ( filename , contents , { encoding : encoding } ) ; logger . info ( { method : "edit_add_cookbook_ids" , filename : filename } , "updated recipe" ) ; } }
This will edit a file and add UDIDs to Chapters

<p>
This is synchronous
This will edit a file and add UDIDs to Chapters