@@ -7,15 +7,28 @@ const cwd = process.cwd();
77/** @type {import("./package.json") | null } */
88const pkg = existsSync ( `${ cwd } /package.json` ) && tryParseJSON ( readFileSync ( `${ cwd } /package.json` , "utf8" ) ) || null ;
99
10- if ( pkg && pkg . name === "@tiddlywiki/mws" && existsSync ( `${ cwd } /mws.dev.mjs` ) ) {
10+ if ( pkg && pkg . name === "@tiddlywiki/mws" && existsSync ( `${ cwd } /mws.dev.mjs` ) ) {
1111 console . error ( "This appears to be a development version of MWS." ) ;
1212 process . exit ( 1 ) ;
1313}
1414
15- if ( pkg && pkg . name === "@tiddlywiki/mws-instance" && pkg . private ) {
15+ if ( pkg && pkg . name === "@tiddlywiki/mws-instance" && pkg . private ) {
16+ if ( pkg . version !== "0.2.0" ) {
17+ console . log ( [
18+ "=======================================================================================" ,
19+ "The data folder you are trying to open appears to be from a different version of MWS." ,
20+ "" ,
21+ "Folder: " + process . cwd ( ) ,
22+ "Version: " + pkg . version ,
23+ "" ,
24+ "To prevent data loss the program will now exit." ,
25+ "=======================================================================================" ,
26+ ] . join ( "\n" ) ) ;
27+ process . exit ( 1 ) ;
28+ }
1629 // need absolute path because of cwd
1730 import ( `file://${ cwd } /node_modules/@tiddlywiki/mws/dist/mws.js` )
18- . then ( mws => mws . default ( ) )
31+ . then ( mws => mws . default ( pkg . version ) )
1932 . catch ( console . error ) ;
2033} else {
2134 console . error ( "This does not appear to be a valid MWS data folder." ) ;
@@ -31,7 +44,7 @@ if(pkg && pkg.name === "@tiddlywiki/mws-instance" && pkg.private) {
3144function tryParseJSON ( file ) {
3245 try {
3346 return JSON . parse ( file ) ;
34- } catch ( e ) {
47+ } catch ( e ) {
3548 return undefined ;
3649 }
3750}
0 commit comments