Skip to content

Commit

Permalink
Merge pull request #9630 from jupyterlab/fcollonval-patch-1
Browse files Browse the repository at this point in the history
Customize template branch when upgrading extension
  • Loading branch information
blink1073 committed Jan 19, 2021
2 parents dffeb0c + 6d6e223 commit 58d4f6d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions jupyterlab/upgrade_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
raise RuntimeError("Please install cookiecutter")


COOKIECUTTER_BRANCH = "3.0"
DEFAULT_COOKIECUTTER_BRANCH = "3.0"


def update_extension(target, interactive=True):
def update_extension(target, branch=DEFAULT_COOKIECUTTER_BRANCH, interactive=True):
"""Update an extension to the current JupyterLab
target: str
Path to the extension directory containing the extension
branch: str [default: DEFAULT_COOKIECUTTER_BRANCH]
Template branch to checkout
interactive: bool [default: true]
Whether to ask before overwriting content
Expand Down Expand Up @@ -63,7 +65,7 @@ def update_extension(target, interactive=True):
)

template = 'https://github.com/jupyterlab/extension-cookiecutter-ts'
cookiecutter(template=template, checkout=COOKIECUTTER_BRANCH, output_dir=output_dir,
cookiecutter(template=template, checkout=branch, output_dir=output_dir,
extra_context=extra_context, no_input=not interactive)

python_name = os.listdir(output_dir)[0]
Expand Down Expand Up @@ -197,7 +199,11 @@ def update_extension(target, interactive=True):
action='store',
type=str,
help='the target path')

parser.add_argument('--branch',
help='the template branch to checkout',
default=DEFAULT_COOKIECUTTER_BRANCH)

args = parser.parse_args()

update_extension(args.path, args.no_input==False)
update_extension(args.path, args.branch, args.no_input==False)

0 comments on commit 58d4f6d

Please sign in to comment.