core/utils/lib/config.js
function(app, file, content, callback) {

        var paths = {
            root : content.paths.root,
            utils : content.paths.utils
        };
        var gnaFolder = content.paths.root + '/.gna';

        self.project = content.project;

        self.paths = paths;

        //Create path.
        var createFolder = function(){
            if ( fs.existsSync(gnaFolder) ) {
                if ( !fs.existsSync(gnaFolder +'/'+ file) ) {
                    createContent(gnaFolder +'/'+ file, gnaFolder, content, function(err){
                        setTimeout(function(){
                            callback(err)
                        }, 500)
                    })
                } else { // already existing ... won't overwrite
                    callback(false)
                }

            } else {
                fs.mkdir(gnaFolder, 0777, function(err){
                    if (err) {
                        console.error(err.stack);
                        callback(err)
                    } else {
                        //Creating content.
                        createContent(gnaFolder+ '/' +file, gnaFolder, content, function(err){
                            setTimeout(function(){
                                callback(err)
                            }, 500)
                        })
                    }
                })
            }

        };

        fs.exists(gnaFolder, function(exists){
            if (!exists) {
                createFolder()
            } else {
                // test if decalred path matches real path and overwrite if not the same
                // in case you move your project
                var filename        = _(gnaFolder +'/'+ file, true);
                var checksumFileOld = _(gnaFolder +'/'+ math.checkSumSync( JSON.stringify( require(filename) ), 'sha1'), true) + '.txt';
                var checksumFile    = _(gnaFolder +'/'+ math.checkSumSync( JSON.stringify(content), 'sha1'), true) + '.txt';

                var verified        = (checksumFileOld == checksumFile) ? true : false;


                if ( !fs.existsSync(checksumFile) && fs.existsSync(filename) || !fs.existsSync(filename) || !verified) {
                    if ( fs.existsSync(filename) ) fs.unlinkSync(filename);
                    if ( fs.existsSync(checksumFile) ) fs.unlinkSync(checksumFile);

                    createContent(filename, gnaFolder, content, function(err){
                        fs.openSync(checksumFile, 'w');
                        setTimeout(function(){
                            callback(err)
                        }, 500)
                    })
                } else if ( fs.existsSync(filename) ) {

                    var locals = require(gnaFolder +'/'+ file);

                    if (paths.utils != locals.paths.utils) {

                        new _(gnaFolder).rm( function(err){
                            if (err) {
                                console.warn('found error while trying to remove `.gna`\n' + err.stack)
                            }

                            //setTimeout(function(){
                                //console.debug('Done removing `gnaFolder` : '+ gnaFolder);
                            createFolder();
                            //}, 200);
                        })
                    } else {
                        callback(false)// nothing to do
                    }
                } else {
                    callback(false)// nothing to do
                }
            }
        })
    }
function(app, file, content, callback) {

        var paths = {
            root : content.paths.root,
            utils : content.paths.utils
        };
        var gnaFolder = content.paths.root + '/.gna';

        self.project = content.project;

        self.paths = paths;

        //Create path.
        var createFolder = function(){
            if ( fs.existsSync(gnaFolder) ) {
                if ( !fs.existsSync(gnaFolder +'/'+ file) ) {
                    createContent(gnaFolder +'/'+ file, gnaFolder, content, function(err){
                        setTimeout(function(){
                            callback(err)
                        }, 500)
                    })
                } else { // already existing ... won't overwrite
                    callback(false)
                }

            } else {
                fs.mkdir(gnaFolder, 0777, function(err){
                    if (err) {
                        console.error(err.stack);
                        callback(err)
                    } else {
                        //Creating content.
                        createContent(gnaFolder+ '/' +file, gnaFolder, content, function(err){
                            setTimeout(function(){
                                callback(err)
                            }, 500)
                        })
                    }
                })
            }

        };

        fs.exists(gnaFolder, function(exists){
            if (!exists) {
                createFolder()
            } else {
                // test if decalred path matches real path and overwrite if not the same
                // in case you move your project
                var filename        = _(gnaFolder +'/'+ file, true);
                var checksumFileOld = _(gnaFolder +'/'+ math.checkSumSync( JSON.stringify( require(filename) ), 'sha1'), true) + '.txt';
                var checksumFile    = _(gnaFolder +'/'+ math.checkSumSync( JSON.stringify(content), 'sha1'), true) + '.txt';

                var verified        = (checksumFileOld == checksumFile) ? true : false;


                if ( !fs.existsSync(checksumFile) && fs.existsSync(filename) || !fs.existsSync(filename) || !verified) {
                    if ( fs.existsSync(filename) ) fs.unlinkSync(filename);
                    if ( fs.existsSync(checksumFile) ) fs.unlinkSync(checksumFile);

                    createContent(filename, gnaFolder, content, function(err){
                        fs.openSync(checksumFile, 'w');
                        setTimeout(function(){
                            callback(err)
                        }, 500)
                    })
                } else if ( fs.existsSync(filename) ) {

                    var locals = require(gnaFolder +'/'+ file);

                    if (paths.utils != locals.paths.utils) {

                        new _(gnaFolder).rm( function(err){
                            if (err) {
                                console.warn('found error while trying to remove `.gna`\n' + err.stack)
                            }

                            //setTimeout(function(){
                                //console.debug('Done removing `gnaFolder` : '+ gnaFolder);
                            createFolder();
                            //}, 200);
                        })
                    } else {
                        callback(false)// nothing to do
                    }
                } else {
                    callback(false)// nothing to do
                }
            }
        })
    }
function ( app , file , content , callback ) { var paths = { root : content . paths . root , utils : content . paths . utils } ; var gnaFolder = content . paths . root + '/.gna' ; self . project = content . project ; self . paths = paths ; //Create path. var createFolder = function ( ) { if ( fs . existsSync ( gnaFolder ) ) { if ( ! fs . existsSync ( gnaFolder + '/' + file ) ) { createContent ( gnaFolder + '/' + file , gnaFolder , content , function ( err ) { setTimeout ( function ( ) { callback ( err ) } , 500 ) } ) } else { // already existing ... won't overwrite callback ( false ) } } else { fs . mkdir ( gnaFolder , 0777 , function ( err ) { if ( err ) { console . error ( err . stack ) ; callback ( err ) } else { //Creating content. createContent ( gnaFolder + '/' + file , gnaFolder , content , function ( err ) { setTimeout ( function ( ) { callback ( err ) } , 500 ) } ) } } ) } } ; fs . exists ( gnaFolder , function ( exists ) { if ( ! exists ) { createFolder ( ) } else { // test if decalred path matches real path and overwrite if not the same // in case you move your project var filename = _ ( gnaFolder + '/' + file , true ) ; var checksumFileOld = _ ( gnaFolder + '/' + math . checkSumSync ( JSON . stringify ( require ( filename ) ) , 'sha1' ) , true ) + '.txt' ; var checksumFile = _ ( gnaFolder + '/' + math . checkSumSync ( JSON . stringify ( content ) , 'sha1' ) , true ) + '.txt' ; var verified = ( checksumFileOld == checksumFile ) ? true : false ; if ( ! fs . existsSync ( checksumFile ) && fs . existsSync ( filename ) || ! fs . existsSync ( filename ) || ! verified ) { if ( fs . existsSync ( filename ) ) fs . unlinkSync ( filename ) ; if ( fs . existsSync ( checksumFile ) ) fs . unlinkSync ( checksumFile ) ; createContent ( filename , gnaFolder , content , function ( err ) { fs . openSync ( checksumFile , 'w' ) ; setTimeout ( function ( ) { callback ( err ) } , 500 ) } ) } else if ( fs . existsSync ( filename ) ) { var locals = require ( gnaFolder + '/' + file ) ; if ( paths . utils != locals . paths . utils ) { new _ ( gnaFolder ) . rm ( function ( err ) { if ( err ) { console . warn ( 'found error while trying to remove `.gna`\n' + err . stack ) } //setTimeout(function(){ //console.debug('Done removing `gnaFolder` : '+ gnaFolder); createFolder ( ) ; //}, 200); } ) } else { callback ( false ) // nothing to do } } else { callback ( false ) // nothing to do } } } ) }
Create a config file

@param {string} app - Targeted application
@param {string} file - File save
@param {string} content - Content fo the file to save


TOTO - Avoid systematics file override.
@private
Create a config file