From 1e2355fc8d23d7a20208ccbafcd15d4e0f7930b1 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Sat, 22 May 2021 12:41:37 +0200 Subject: [PATCH] Properly install NPM Packages --- jupyter_releaser/lib.py | 17 ++++++++++++++--- jupyter_releaser/util.py | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/jupyter_releaser/lib.py b/jupyter_releaser/lib.py index 1d6d7101..84ba7666 100644 --- a/jupyter_releaser/lib.py +++ b/jupyter_releaser/lib.py @@ -478,9 +478,20 @@ def prep_git(ref, branch, repo, auth, username, url, install=True): else: util.run(checkout_cmd) - # Install the package with test deps - if util.SETUP_PY.exists() and install: - util.run('pip install ".[test]"') + # Install the package + if install: + # install python package with test deps + if util.SETUP_PY.exists(): + util.run('pip install ".[test]"') + + # prefer yarn if yarn lock exists + elif util.YARN_LOCK.exists(): + util.run("npm install -g yarn") + util.run("yarn") + + # npm install otherwise + elif util.PACKAGE_JSON.exists(): + util.run("npm install") os.chdir(orig_dir) diff --git a/jupyter_releaser/util.py b/jupyter_releaser/util.py index ab22148f..b4e70237 100644 --- a/jupyter_releaser/util.py +++ b/jupyter_releaser/util.py @@ -22,6 +22,7 @@ SETUP_PY = Path("setup.py") SETUP_CFG = Path("setup.cfg") PACKAGE_JSON = Path("package.json") +YARN_LOCK = Path("yarn.lock") jupyter_releaser_CONFIG = Path(".jupyter-releaser.toml") BUF_SIZE = 65536