function writePath(parentDir, path, data) {
    path = path.replace(/\/+/g, '/').replace(/\/+$/, '');
    let files = path.split('/');
    let file = files.shift();

    // init file
    if(!parentDir[file]) parentDir[file] = {
        content: undefined,
        tree: {}
    };

    if(files.length > 0) {
        writePath(parentDir[file].tree, files.join('/'), data);
    } else if(data) {
        parentDir[file].content = data;
    }
}
/**
 * Recursively creates a file
 * @param parentDir
 * @param path
 * @param data
 */
Recursively creates a file
@param parentDir
@param path
@param data
Recursively creates a file @param parentDir @param path @param data
function writePath(parentDir, path, data) {
    path = path.replace(/\/+/g, '/').replace(/\/+$/, '');
    let files = path.split('/');
    let file = files.shift();
    if(!parentDir[file]) parentDir[file] = {
        content: undefined,
        tree: {}
    };
    if(files.length > 0) {
        writePath(parentDir[file].tree, files.join('/'), data);
    } else if(data) {
        parentDir[file].content = data;
    }
}
function writePath ( parentDir , path , data ) { path = path . replace ( / \/+ / g , '/' ) . replace ( / \/+$ / , '' ) ; let files = path . split ( '/' ) ; let file = files . shift ( ) ; if ( ! parentDir [ file ] ) parentDir [ file ] = { content : undefined , tree : { } } ; if ( files . length > 0 ) { writePath ( parentDir [ file ] . tree , files . join ( '/' ) , data ) ; } else if ( data ) { parentDir [ file ] . content = data ; } }
Recursively creates a file
 @param parentDir
 @param path
 @param data
Recursively creates a file @param parentDir @param path @param data
// init file