File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change 1
1
import * as path from 'path' ;
2
2
import * as Shelljs from 'shelljs' ;
3
3
4
+ import { isGlobal } from '../../utilities' ;
5
+
4
6
export class NgdEngine {
5
7
constructor ( ) {
6
8
7
9
}
8
10
renderGraph ( filepath :String , outputpath : String , type : String ) {
9
11
return new Promise ( function ( resolve , reject ) {
10
- Shelljs . exec ( path . resolve ( __dirname + '/../node_modules/.bin/ngd' ) + ' -' + type + ' ' + filepath + ' -d ' + outputpath + ' -s -t svg' , {
12
+ let ngdPath = ( isGlobal ( ) ) ? __dirname + '/../node_modules/.bin/ngd' : __dirname + '/../../.bin/ngd' ;
13
+ let finalPath = path . resolve ( ngdPath ) + ' -' + type + ' ' + filepath + ' -d ' + outputpath + ' -s -t svg'
14
+ Shelljs . exec ( finalPath , {
11
15
silent : true
12
16
} , function ( code , stdout , stderr ) {
13
17
if ( code === 0 ) {
Original file line number Diff line number Diff line change @@ -23,6 +23,25 @@ export function getNewLineCharacter(options: ts.CompilerOptions): string {
23
23
return carriageReturnLineFeed ;
24
24
}
25
25
26
+ export function isGlobal ( ) {
27
+ var isGlobal = false ;
28
+
29
+ if ( process . platform === "win32" ) {
30
+ var paths = process . env . Path . split ( ";" ) ;
31
+ for ( var i = 0 ; i < paths . length ; i ++ ) {
32
+ if ( paths [ i ] . indexOf ( "npm" ) !== - 1 &&
33
+ process . mainModule . filename . indexOf ( paths [ i ] ) !== - 1 ) {
34
+ isGlobal = true ;
35
+ break ;
36
+ }
37
+ }
38
+ } else {
39
+ isGlobal = process . env . _ !== process . execPath ;
40
+ }
41
+
42
+ return isGlobal ;
43
+ }
44
+
26
45
export function detectIndent ( str , count , indent ?) : string {
27
46
let stripIndent = function ( str : string ) {
28
47
const match = str . match ( / ^ [ \t ] * (? = \S ) / gm) ;
You can’t perform that action at this time.
0 commit comments