diff --git a/.gitignore b/.gitignore index ea741a11..01888845 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,5 @@ cypress/screenshots dist .opt-in .eslintcache +/client/other/shared +/server/other/shared diff --git a/client/other/shared b/client/other/shared deleted file mode 120000 index 5b802bae..00000000 --- a/client/other/shared +++ /dev/null @@ -1 +0,0 @@ -/Users/kdodds/Developer/testing-workshop/shared \ No newline at end of file diff --git a/package.json b/package.json index 820c9f70..90db0f3b 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "eslint": "^4.16.0", "eslint-config-kentcdodds": "^13.0.1", "faker": "^4.1.0", + "fs-extra": "^5.0.0", "husky": "^0.14.3", "jest": "^22.1.2", "lint-staged": "^6.0.1", diff --git a/scripts/install.js b/scripts/install.js index 3b260f54..0b9eaa05 100644 --- a/scripts/install.js +++ b/scripts/install.js @@ -1,17 +1,43 @@ /* eslint-disable */ -var path = require('path') -var installDeps = require('./workshop-setup').installDeps +const path = require('path') +const fs = require('fs') +const installDeps = require('./workshop-setup').installDeps + +ensureExists(path.resolve(__dirname, '../client/other')) +ensureExists(path.resolve(__dirname, '../server/other')) + +symlinkDir( + path.resolve(__dirname, '../shared/'), + path.resolve(__dirname, '../client/other/shared') +) +symlinkDir( + path.resolve(__dirname, '../shared/'), + path.resolve(__dirname, '../server/other/shared') +) + +const main = path.resolve(__dirname, '..') +const shared = path.resolve(__dirname, '../shared') +const server = path.resolve(__dirname, '../server') +const client = path.resolve(__dirname, '../client') -var main = path.resolve(__dirname, '..') -var shared = path.resolve(__dirname, '../shared') -var server = path.resolve(__dirname, '../server') -var client = path.resolve(__dirname, '../client') installDeps([main, shared, server, client]).then( - function() { + () => { console.log('👍 all dependencies installed') }, - function() { + () => { // ignore, workshop-setup will log for us... - } + }, ) + +function symlinkDir(src, dest) { + if (!fs.existsSync(dest)) { + fs.symlinkSync(src, dest, 'dir') + } +} + +function ensureExists(dir) { + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir) + } +} diff --git a/server/other/shared b/server/other/shared deleted file mode 120000 index 5b802bae..00000000 --- a/server/other/shared +++ /dev/null @@ -1 +0,0 @@ -/Users/kdodds/Developer/testing-workshop/shared \ No newline at end of file