2021-07-03 18:50:22 +05:30
const fs = require ( "fs" ) ;
2021-07-05 22:29:35 +05:30
const updateReadme = ( ) => {
const excalidrawDir = ` ${ _ _dirname } /../src/packages/excalidraw ` ;
let data = fs . readFileSync ( ` ${ excalidrawDir } /README_NEXT.md ` , "utf8" ) ;
2021-07-03 18:50:22 +05:30
2021-07-05 22:29:35 +05:30
// remove note for unstable release
data = data . replace (
/<!-- unstable-readme-start-->[\s\S]*?<!-- unstable-readme-end-->/ ,
"" ,
) ;
2021-07-03 18:50:22 +05:30
2021-07-05 22:29:35 +05:30
// replace "excalidraw-next" with "excalidraw"
data = data . replace ( /excalidraw-next/g , "excalidraw" ) ;
data = data . trim ( ) ;
2021-07-03 18:50:22 +05:30
2021-07-05 22:29:35 +05:30
const demoIndex = data . indexOf ( "### Demo" ) ;
const excalidrawNextNote =
"#### Note\n\n**If you don't want to wait for the next stable release and try out the unreleased changes you can use [@excalidraw/excalidraw-next](https://www.npmjs.com/package/@excalidraw/excalidraw-next).**\n\n" ;
// Add excalidraw next note to try out for unreleased changes
data = data . slice ( 0 , demoIndex ) + excalidrawNextNote + data . slice ( demoIndex ) ;
2021-07-03 18:50:22 +05:30
2021-07-05 22:29:35 +05:30
// update readme
fs . writeFileSync ( ` ${ excalidrawDir } /README.md ` , data , "utf8" ) ;
} ;
module . exports = updateReadme ;