Skip to content

Commit

Permalink
Merge pull request #71 from afshin/install-npm
Browse files Browse the repository at this point in the history
Fix Usage of install_npm
  • Loading branch information
blink1073 authored Mar 24, 2021
2 parents a78cbf4 + 612e3f3 commit 71a3a5b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion jupyter_packaging/setupbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def install_npm(path=None, build_dir=None, source_dir=None, build_cmd='build',
npm: str or list, optional.
The npm executable name, or a tuple of ['node', executable].
"""
npm_builder(path=path, build_dir=build_dir, source_dir=source_dir, build_cmd=build_cmd, force=force, npm=npm)
builder = npm_builder(path=path, build_dir=build_dir, source_dir=source_dir, build_cmd=build_cmd, force=force, npm=npm)

class NPM(BaseCommand):
description = 'install package.json dependencies using npm'
Expand Down
18 changes: 15 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import json
import os
import pathlib
from pytest import fixture
from subprocess import run

HERE = pathlib.Path(__file__).resolve()

PACKAGE_JSON = json.dumps(dict(
name="foo",
version="0.1.0",
scripts=dict(build="echo 'hi'")
))


@fixture(scope="session", autouse=True)
def clear_pip_cache():
Expand Down Expand Up @@ -59,14 +66,16 @@ def exclude(filename):
)

setup_maker_deprecated = lambda name="jupyter_packaging_test_foo", data_files_spec=None, **kwargs: """
from jupyter_packaging import create_cmdclass
from jupyter_packaging import create_cmdclass, install_npm
import setuptools
import os
def exclude(filename):
return os.path.basename(filename) == "exclude.py"
cmdclass = create_cmdclass(data_files_spec={data_files_spec}, exclude=exclude)
cmdclass = create_cmdclass('jsdeps', data_files_spec={data_files_spec}, exclude=exclude)
cmdclass['jsdeps'] = install_npm()
setuptools.setup(cmdclass=cmdclass, {setup_args})
""".format(
Expand Down Expand Up @@ -147,7 +156,10 @@ def make_package_deprecated(tmp_path, pyproject_toml):
"""A callable fixture that creates a mock python package
in tmp_path and returns the package directory
"""
return make_package_base(tmp_path, pyproject_toml, setup_func=setup_maker_deprecated)
package = make_package_base(tmp_path, pyproject_toml, setup_func=setup_maker_deprecated)
package_json = tmp_path / "package.json"
package_json.write_text(PACKAGE_JSON, encoding='utf-8')
return package


@fixture
Expand Down

0 comments on commit 71a3a5b

Please sign in to comment.