@@ -627,5 +627,97 @@ namespace ts.projectSystem {
627
627
checkProjectActualFiles ( p1 , [ lodashJs . path , commanderJs . path , file3 . path , commander . path , jquery . path , lodash . path , cordova . path ] ) ;
628
628
checkProjectActualFiles ( p2 , [ file3 . path , grunt . path , gulp . path ] ) ;
629
629
} ) ;
630
+
631
+ it ( "configured projects discover from node_modules" , ( ) => {
632
+ const app = {
633
+ path : "/app.js" ,
634
+ content : ""
635
+ } ;
636
+ const jsconfig = {
637
+ path : "/jsconfig.json" ,
638
+ content : JSON . stringify ( { } )
639
+ } ;
640
+ const jquery = {
641
+ path : "/node_modules/jquery/index.js" ,
642
+ content : ""
643
+ } ;
644
+ const jqueryPackage = {
645
+ path : "/node_modules/jquery/package.json" ,
646
+ content : JSON . stringify ( { name : "jquery" } )
647
+ } ;
648
+ const jqueryDTS = {
649
+ path : "/tmp/node_modules/@types/jquery/index.d.ts" ,
650
+ content : ""
651
+ } ;
652
+ const host = createServerHost ( [ app , jsconfig , jquery , jqueryPackage ] ) ;
653
+ const installer = new ( class extends Installer {
654
+ constructor ( ) {
655
+ super ( host , { globalTypingsCacheLocation : "/tmp" } ) ;
656
+ }
657
+ runCommand ( requestKind : TI . RequestKind , requestId : number , command : string , cwd : string , cb : server . typingsInstaller . RequestCompletedAction ) {
658
+ const installedTypings = [ "@types/jquery" ] ;
659
+ const typingFiles = [ jqueryDTS ] ;
660
+ executeCommand ( this , host , installedTypings , typingFiles , requestKind , cb ) ;
661
+ }
662
+ } ) ( ) ;
663
+
664
+ const projectService = createProjectService ( host , { useSingleInferredProject : true , typingsInstaller : installer } ) ;
665
+ projectService . openClientFile ( app . path ) ;
666
+
667
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
668
+ const p = projectService . configuredProjects [ 0 ] ;
669
+ checkProjectActualFiles ( p , [ app . path ] ) ;
670
+
671
+ installer . installAll ( [ TI . NpmViewRequest ] , [ TI . NpmInstallRequest ] ) ;
672
+
673
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
674
+ checkProjectActualFiles ( p , [ app . path , jqueryDTS . path ] ) ;
675
+ } ) ;
676
+
677
+ it ( "configured projects discover from bower.josn" , ( ) => {
678
+ const app = {
679
+ path : "/app.js" ,
680
+ content : ""
681
+ } ;
682
+ const jsconfig = {
683
+ path : "/jsconfig.json" ,
684
+ content : JSON . stringify ( { } )
685
+ } ;
686
+ const bowerJson = {
687
+ path : "/bower.json" ,
688
+ content : JSON . stringify ( {
689
+ "dependencies" : {
690
+ "jquery" : "^3.1.0"
691
+ }
692
+ } )
693
+ } ;
694
+ const jqueryDTS = {
695
+ path : "/tmp/node_modules/@types/jquery/index.d.ts" ,
696
+ content : ""
697
+ } ;
698
+ const host = createServerHost ( [ app , jsconfig , bowerJson ] ) ;
699
+ const installer = new ( class extends Installer {
700
+ constructor ( ) {
701
+ super ( host , { globalTypingsCacheLocation : "/tmp" } ) ;
702
+ }
703
+ runCommand ( requestKind : TI . RequestKind , requestId : number , command : string , cwd : string , cb : server . typingsInstaller . RequestCompletedAction ) {
704
+ const installedTypings = [ "@types/jquery" ] ;
705
+ const typingFiles = [ jqueryDTS ] ;
706
+ executeCommand ( this , host , installedTypings , typingFiles , requestKind , cb ) ;
707
+ }
708
+ } ) ( ) ;
709
+
710
+ const projectService = createProjectService ( host , { useSingleInferredProject : true , typingsInstaller : installer } ) ;
711
+ projectService . openClientFile ( app . path ) ;
712
+
713
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
714
+ const p = projectService . configuredProjects [ 0 ] ;
715
+ checkProjectActualFiles ( p , [ app . path ] ) ;
716
+
717
+ installer . installAll ( [ TI . NpmViewRequest ] , [ TI . NpmInstallRequest ] ) ;
718
+
719
+ checkNumberOfProjects ( projectService , { configuredProjects : 1 } ) ;
720
+ checkProjectActualFiles ( p , [ app . path , jqueryDTS . path ] ) ;
721
+ } ) ;
630
722
} ) ;
631
723
}
0 commit comments