Skip to content
This repository was archived by the owner on Jan 22, 2021. It is now read-only.

Commit 94e07dd

Browse files
John McCormackJohn McCormack
John McCormack
authored and
John McCormack
committed
automate setting the ROOT variable
1 parent 1ba0ccb commit 94e07dd

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

utils.coffee

+16-7
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,24 @@ TAG = 'mailer-utils'
1717
# /var/www/app/bundle
1818
# For Modulus, you need to use the APP_DIR variable, which you do NOT need to set
1919

20-
if process.env.BUNDLE_PATH
21-
ROOT = path.join(process.env.BUNDLE_PATH, 'programs', 'server', 'assets', 'app')
22-
else if process.env.APP_DIR
23-
ROOT = path.join(process.env.APP_DIR, 'programs','server', 'assets', 'app')
24-
else
20+
isDevEnv = ->
21+
process.env.NODE_ENV == 'development'
2522

23+
developmentPrivateDir = ->
24+
return unless isDevEnv()
2625
# In development, using pwd is fine. Remove the .meteor/foo/bar stuff though.
27-
realPath = process.cwd().replace(/(\.meteor.*)/g, '')
28-
ROOT = path.join(realPath, 'private')
26+
meteor_root = process.cwd().replace(/(\.meteor.*)/g, '')
27+
path.join(meteor_root, 'private')
28+
29+
productionPrivateDir = ->
30+
return if isDevEnv()
31+
meteor_root = fs.realpathSync( process.cwd() + '/../' )
32+
fs.realpathSync( meteor_root + '/../' )
33+
34+
privateDir = process.env.BUNDLE_PATH || process.env.APP_DIR || productionPrivateDir()
35+
ROOT = privateDir && path.join(privateDir, 'programs', 'server', 'assets', 'app')
36+
ROOT ||= developmentPrivateDir()
37+
2938

3039
Utils =
3140

0 commit comments

Comments
 (0)