add the ability to link extra files into the build directory

This commit is contained in:
Brian Hicks 2023-05-03 15:35:09 -05:00
parent 76c9c22bc6
commit ecfce394df
No known key found for this signature in database
GPG Key ID: C4F324B9CAAB0D50

View File

@ -26,6 +26,12 @@ if __name__ == "__main__":
"--bin-dir",
help="Path to a node installation's binary directory. If present, will be treated as an extra entry in PATH for the duration of this command.",
)
parser.add_argument(
"--extra-file",
action="append",
metavar="FILE=SRC",
help="Add a file that the package needs, sourced from the given path. This may be used, for example, to add files needed by a prepublish script.",
)
args = parser.parse_args()
@ -40,6 +46,16 @@ if __name__ == "__main__":
shutil.copy(args.package, os.path.join(tempdir, "package.json"))
shutil.copy(args.package_lock, os.path.join(tempdir, "package-lock.json"))
# grab extra files that may be needed
for extra in args.extra_file or []:
target, src = extra.split("=")
dir = os.path.dirname(target)
if dir:
os.makedirs(os.path.join(tempdir, dir))
os.symlink(os.path.abspath(src), os.path.join(tempdir, target))
cmd = ["npm", "clean-install", "--foreground-scripts"]
proc = subprocess.Popen(cmd, cwd=tempdir)