@@ -348,7 +348,26 @@ def should_run_npm(self):
348
348
if not os .path .exists (self .node_modules ):
349
349
return True
350
350
return mtime (self .node_modules ) < mtime (pjoin (repo_root , 'package.json' ))
351
-
351
+
352
+ def npm_components (self ):
353
+ """Stage npm frontend dependencies into components"""
354
+ for pkg in ['preact' , 'preact-compat' , 'proptypes' ]:
355
+ npm_pkg = os .path .join (self .node_modules , pkg )
356
+ bower_pkg = os .path .join (self .bower_dir , pkg )
357
+ log .info ("Staging %s -> %s" % (npm_pkg , bower_pkg ))
358
+ if os .path .exists (bower_pkg ):
359
+ shutil .rmtree (bower_pkg )
360
+ shutil .copytree (npm_pkg , bower_pkg )
361
+
362
+ def patch_codemirror (self ):
363
+ """Patch CodeMirror until https://github.com/codemirror/CodeMirror/issues/4454 is resolved"""
364
+
365
+ try :
366
+ shutil .copyfile ('tools/patches/codemirror.js' , 'notebook/static/components/codemirror/lib/codemirror.js' )
367
+ except OSError as e :
368
+ print ("Failed to patch codemirror.js: %s" % e , file = sys .stderr )
369
+ raise
370
+
352
371
def run (self ):
353
372
if not self .should_run ():
354
373
print ("bower dependencies up to date" )
@@ -372,6 +391,9 @@ def run(self):
372
391
print ("Failed to run bower: %s" % e , file = sys .stderr )
373
392
print ("You can install js dependencies with `npm install`" , file = sys .stderr )
374
393
raise
394
+
395
+ self .patch_codemirror ()
396
+ self .npm_components ()
375
397
os .utime (self .bower_dir , None )
376
398
# update package data in case this created new files
377
399
update_package_data (self .distribution )
0 commit comments