Skip to content

Commit

Permalink
Backport PR jupyter#2066 on branch 4.x
Browse files Browse the repository at this point in the history
Merge pull request jupyter#2066 from jupyter/cm-up

Patch CodeMirror 5.22
  • Loading branch information
minrk authored and Carreau committed Jan 31, 2017
1 parent 0273b3f commit 6789afd
Show file tree
Hide file tree
Showing 3 changed files with 9,150 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"backbone": "components/backbone#~1.2",
"bootstrap": "components/bootstrap#~3.3",
"bootstrap-tour": "0.9.0",
"codemirror": "components/codemirror#~5.16",
"codemirror": "components/codemirror#~5.22.2",
"es6-promise": "~1.0",
"font-awesome": "components/font-awesome#~4.2.0",
"google-caja": "5669",
Expand Down
26 changes: 25 additions & 1 deletion setupbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,26 @@ def should_run_npm(self):
if not os.path.exists(self.node_modules):
return True
return mtime(self.node_modules) < mtime(pjoin(repo_root, 'package.json'))


def npm_components(self):
"""Stage npm frontend dependencies into components"""
for pkg in ['preact', 'preact-compat', 'proptypes']:
npm_pkg = os.path.join(self.node_modules, pkg)
bower_pkg = os.path.join(self.bower_dir, pkg)
log.info("Staging %s -> %s" % (npm_pkg, bower_pkg))
if os.path.exists(bower_pkg):
shutil.rmtree(bower_pkg)
shutil.copytree(npm_pkg, bower_pkg)

def patch_codemirror(self):
"""Patch CodeMirror until https://github.com/codemirror/CodeMirror/issues/4454 is resolved"""

try:
shutil.copyfile('tools/patches/codemirror.js', 'notebook/static/components/codemirror/lib/codemirror.js')
except OSError as e:
print("Failed to patch codemirror.js: %s" % e, file=sys.stderr)
raise

def run(self):
if not self.should_run():
print("bower dependencies up to date")
Expand All @@ -372,6 +391,11 @@ def run(self):
print("Failed to run bower: %s" % e, file=sys.stderr)
print("You can install js dependencies with `npm install`", file=sys.stderr)
raise
<<<<<<< HEAD
=======
self.patch_codemirror()
self.npm_components()
>>>>>>> 393a04d1b... Merge pull request #2066 from jupyter/cm-up
os.utime(self.bower_dir, None)
# update package data in case this created new files
update_package_data(self.distribution)
Expand Down
Loading

0 comments on commit 6789afd

Please sign in to comment.