lib/pathutils.js
function file( path, content ) {
    try {
        if ( typeof content === 'undefined' ) {
            if ( !FS.existsSync( path ) ) return null;
            return FS.readFileSync( path );
        }
        const dir = Path.dirname( path );
        mkdir( dir );
        FS.writeFileSync( path, content );
        return content;
    } catch ( ex ) {
        console.warn( "content:", content );
        throw new Error( `${ex}\n...in pathutils/file("${path}", ${typeof content})` );
    }
}
function file( path, content ) {
    try {
        if ( typeof content === 'undefined' ) {
            if ( !FS.existsSync( path ) ) return null;
            return FS.readFileSync( path );
        }
        const dir = Path.dirname( path );
        mkdir( dir );
        FS.writeFileSync( path, content );
        return content;
    } catch ( ex ) {
        console.warn( "content:", content );
        throw new Error( `${ex}\n...in pathutils/file("${path}", ${typeof content})` );
    }
}
function file ( path , content ) { try { if ( typeof content === 'undefined' ) { if ( ! FS . existsSync ( path ) ) return null ; return FS . readFileSync ( path ) ; } const dir = Path . dirname ( path ) ; mkdir ( dir ) ; FS . writeFileSync ( path , content ) ; return content ; } catch ( ex ) { console . warn ( "content:" , content ) ; throw new Error ( ` ${ ex } \n ${ path } ${ typeof content } ` ) ; } }
Read or write the content of a file.

If  `content` is  undefined, the  content  is read,  otherwise it  is
written.
If the  file to be  written is in  a non-existent subfolder,  the whole
path will be created with the `mkdir`function.

@param {string} path - Path of the file to read or write.
@param {string} content - Optional. If omitted, we return the content of the file.
Otherwise, we save this content to the file.
@returns {string} The file content.
Read or write the content of a file .