From ffe91f950b130ea28d1078519e85864e1b3bcc75 Mon Sep 17 00:00:00 2001
From: Jure Triglav <juretriglav@gmail.com>
Date: Wed, 30 Sep 2020 10:51:13 +0200
Subject: [PATCH] feat: add yarn console with preloaded models

---
 package.json       | 3 ++-
 scripts/preload.js | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 scripts/preload.js

diff --git a/package.json b/package.json
index acd19898ef..e5ee13f17d 100644
--- a/package.json
+++ b/package.json
@@ -160,7 +160,8 @@
     "test:chrome": "cypress run --browser chrome",
     "__cleanNodeModules": "find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \\;",
     "build": "NODE_ENV=production pubsweet build",
-    "seedFromDump": "node scripts/seedFromDump.js"
+    "seedFromDump": "node scripts/seedFromDump.js",
+    "console": "node --experimental-repl-await -r ./scripts/preload.js"
   },
   "jest": {
     "testEnvironment": "node",
diff --git a/scripts/preload.js b/scripts/preload.js
new file mode 100644
index 0000000000..6936900ace
--- /dev/null
+++ b/scripts/preload.js
@@ -0,0 +1,3 @@
+const models = require('@pubsweet/models')
+
+Object.keys(models).forEach(key => (global[key] = models[key]))
-- 
GitLab