import fs from 'fs' ; import path from 'path' ; const docsReadmeFilePath = path . resolve ( __dirname , '../docs/README.md' ) ; const rootReadmeFilePath = path . resolve ( __dirname , '../README.md' ) ; fs . readFile ( docsReadmeFilePath , 'utf8' , ( err , data ) => { if ( err ) throw err ; const rootReadmeFileContents = data . replace ( /(\.\/)/g , '/docs/' ) ; fs . writeFile ( rootReadmeFilePath , rootReadmeFileContents , ( err ) => { if ( err ) throw err ; console . log ( 'README.md succcessfully copied to the root directory.' ) ; } ) ; } ) ;