File tree Expand file tree Collapse file tree 7 files changed +39
-4
lines changed Expand file tree Collapse file tree 7 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ var path = require('path');
3
3
var fs = require ( 'fs' ) ;
4
4
var os = require ( 'os' ) ;
5
5
var textBuffer = require ( 'basarat-text-buffer' ) ;
6
+ var typescriptServices_1 = require ( "../typescriptServices" ) ;
6
7
function createScriptInfo ( fileName , text , isOpen ) {
7
8
if ( isOpen === void 0 ) { isOpen = false ; }
8
9
var version = 1 ;
@@ -118,11 +119,19 @@ function getScriptSnapShot(scriptInfo) {
118
119
getChangeRange : getChangeRange ,
119
120
} ;
120
121
}
122
+ function getTypescriptLocation ( ) {
123
+ if ( typescriptServices_1 . typescriptServices ) {
124
+ return path . dirname ( typescriptServices_1 . typescriptServices ) ;
125
+ }
126
+ else {
127
+ return path . dirname ( require . resolve ( 'ntypescript' ) ) ;
128
+ }
129
+ }
121
130
exports . getDefaultLibFilePath = function ( options ) {
122
131
var filename = ts . getDefaultLibFileName ( options ) ;
123
- return ( path . join ( path . dirname ( require . resolve ( 'ntypescript' ) ) , filename ) ) . split ( '\\' ) . join ( '/' ) ;
132
+ return ( path . join ( getTypescriptLocation ( ) , filename ) ) . split ( '\\' ) . join ( '/' ) ;
124
133
} ;
125
- exports . typescriptDirectory = path . dirname ( require . resolve ( 'ntypescript' ) ) . split ( '\\' ) . join ( '/' ) ;
134
+ exports . typescriptDirectory = getTypescriptLocation ( ) . split ( '\\' ) . join ( '/' ) ;
126
135
var LanguageServiceHost = ( function ( ) {
127
136
function LanguageServiceHost ( config ) {
128
137
var _this = this ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ exports . typescriptServices = '' ;
3
+ function setTypescriptServices ( path ) {
4
+ exports . typescriptServices = path ;
5
+ }
6
+ exports . setTypescriptServices = setTypescriptServices ;
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ if (process.argv.length > 2) {
5
5
}
6
6
var makeTypeScriptGlobal_1 = require ( "../typescript/makeTypeScriptGlobal" ) ;
7
7
makeTypeScriptGlobal_1 . makeTsGlobal ( typescriptServices ) ;
8
+ var typescriptServices_1 = require ( "../main/lang/typescriptServices" ) ;
9
+ typescriptServices_1 . setTypescriptServices ( typescriptServices ) ;
8
10
var workerLib = require ( './lib/workerLib' ) ;
9
11
var child = new workerLib . Child ( ) ;
10
12
var projectCache = require ( "../main/lang/projectCache" ) ;
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import os = require('os')
5
5
import textBuffer = require( 'basarat-text-buffer' ) ;
6
6
7
7
import tsconfig = require( '../../tsconfig/tsconfig' ) ;
8
+ import { typescriptServices } from "../typescriptServices" ;
8
9
9
10
interface ScriptInfo {
10
11
getFileName ( ) : string ;
@@ -203,12 +204,21 @@ function getScriptSnapShot(scriptInfo: ScriptInfo): ts.IScriptSnapshot {
203
204
}
204
205
}
205
206
207
+ function getTypescriptLocation ( ) {
208
+ if ( typescriptServices ) {
209
+ return path . dirname ( typescriptServices ) ;
210
+ }
211
+ else {
212
+ return path . dirname ( require . resolve ( 'ntypescript' ) ) ;
213
+ }
214
+ }
215
+
206
216
export var getDefaultLibFilePath = ( options : ts . CompilerOptions ) => {
207
217
var filename = ts . getDefaultLibFileName ( options ) ;
208
- return ( path . join ( path . dirname ( require . resolve ( 'ntypescript' ) ) , filename ) ) . split ( '\\' ) . join ( '/' ) ;
218
+ return ( path . join ( getTypescriptLocation ( ) , filename ) ) . split ( '\\' ) . join ( '/' ) ;
209
219
}
210
220
211
- export var typescriptDirectory = path . dirname ( require . resolve ( 'ntypescript' ) ) . split ( '\\' ) . join ( '/' ) ;
221
+ export var typescriptDirectory = getTypescriptLocation ( ) . split ( '\\' ) . join ( '/' ) ;
212
222
213
223
214
224
// NOTES:
Original file line number Diff line number Diff line change
1
+ export var typescriptServices = '' ;
2
+
3
+ export function setTypescriptServices ( path : string ) {
4
+ typescriptServices = path ;
5
+ }
Original file line number Diff line number Diff line change 92
92
" ./main/lang/transformers/implementations/nullTransformer.ts" ,
93
93
" ./main/lang/transformers/transformer.ts" ,
94
94
" ./main/lang/transformers/transformerRegistry.ts" ,
95
+ " ./main/lang/typescriptServices.ts" ,
95
96
" ./main/lang/utils.ts" ,
96
97
" ./main/react/htmltotsx.ts" ,
97
98
" ./main/tsconfig/dts-generator.ts" ,
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ if (process.argv.length > 2) {
5
5
// setup typescript
6
6
import { makeTsGlobal } from "../typescript/makeTypeScriptGlobal" ;
7
7
makeTsGlobal ( typescriptServices ) ;
8
+ import { setTypescriptServices } from "../main/lang/typescriptServices" ;
9
+ setTypescriptServices ( typescriptServices ) ;
8
10
9
11
import workerLib = require( './lib/workerLib' ) ;
10
12
You can’t perform that action at this time.
0 commit comments