Last active
June 1, 2020 00:02
-
-
Save mranawake/1c4723d8e01d2309e25f76f491667672 to your computer and use it in GitHub Desktop.
AWS Lambda mounts Lambda Layers to /opt/nodejs/src and development source must be kept at /lib/<module_name>/nodejs. This causes problems with some IDEs not being able to find source to provide code hints. Above simple shell script will create symlinks to overcome this problem.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import glob | |
import sys | |
# variables | |
srcBase = "lib/nodejs/src/" | |
cwd = os.getcwd() | |
if len(sys.argv) == 3: | |
sb = cwd + "/lib/" + sys.argv[1] + "/nodejs/src/*." + sys.argv[2] | |
tb = cwd + "/opt/nodejs/src/" | |
else: | |
sb = cwd + "/lib/" + sys.argv[1] + "/nodejs/src/" + sys.argv[3] + "/*." + sys.argv[2] | |
tb = cwd + "/opt/nodejs/src/" + sys.argv[3] + "/" | |
# create base folder structure | |
if not os.path.exists(tb): | |
os.makedirs(tb) | |
targets = glob.glob(sb) | |
for target in targets: | |
file = os.path.basename(target) | |
path = tb + file | |
if not os.path.islink(path): | |
os.symlink(target, path) | |
print file + " --> " + target | |
else: | |
print "link " + file + " found ... skipping." | |
# assumption - assumes you are saving your layer under "/lib/<module_name>/nodejs" local folder. | |
# usage - python mount.py <src_folder> <extension> <sub_folder> | |
# eg1 - python mount.py helpers js | |
# eg2 - python mount.py helpers json models |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment