File tree Expand file tree Collapse file tree 5 files changed +48
-14
lines changed Expand file tree Collapse file tree 5 files changed +48
-14
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
9
9
## [ Unreleased]
10
10
11
+ ### Added
12
+
13
+ - A ` tarantool.ttPath ` configuration option can now be used to specify a path to
14
+ TT utility if it's not available in the ` $PATH ` .
15
+
11
16
### Changed
12
17
13
18
- Now the extension automatically setups Tarantool annotations without need to
Original file line number Diff line number Diff line change 75
75
],
76
76
"url" : " https://download.tarantool.org/tarantool/schema/config.schema.json"
77
77
}
78
- ]
78
+ ],
79
+ "configuration" : {
80
+ "title" : " Tarantool" ,
81
+ "properties" : {
82
+ "tarantool.ttPath" : {
83
+ "type" : " string" ,
84
+ "default" : " tt" ,
85
+ "markdownDescription" : " Specifies a path to the TT executable, defaults to the one available in the `$PATH`."
86
+ }
87
+ }
88
+ }
79
89
},
80
90
"scripts" : {
81
91
"vscode:prepublish" : " npm run package" ,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import * as tt from './tt';
3
3
import * as fs from 'fs' ;
4
4
import * as os from 'os' ;
5
5
import * as _ from 'lodash' ;
6
+ import * as utils from './utils' ;
6
7
7
8
const annotationsPaths = [
8
9
__dirname + "/Library" ,
@@ -43,21 +44,12 @@ async function initGlobalEmmyrc() {
43
44
}
44
45
45
46
async function initVs ( ) {
46
- const file = vscode . window . activeTextEditor ?. document . uri . fsPath ;
47
-
48
- const wsedit = new vscode . WorkspaceEdit ( ) ;
49
- const wsFolders = vscode . workspace . workspaceFolders ?. map ( ( folder ) => folder . uri . fsPath ) ;
50
- if ( ! wsFolders ) {
51
- vscode . window . showWarningMessage ( 'Please, open a project before running this command' ) ;
52
- return ;
53
- }
54
-
55
- const wsPath = file ? wsFolders . find ( ( folder ) => file . startsWith ( folder ) ) : wsFolders . at ( 0 ) ;
47
+ const wsPath = utils . fetchWsFolder ( { showWarning : true } ) ?. uri . fsPath ;
56
48
if ( ! wsPath ) {
57
- vscode . window . showWarningMessage ( 'Please, open at least one folder within the workspace' ) ;
58
49
return ;
59
50
}
60
51
52
+ const wsedit = new vscode . WorkspaceEdit ( ) ;
61
53
const filePath = vscode . Uri . file ( `${ wsPath } /${ emmyrcFile } ` ) ;
62
54
if ( fs . existsSync ( filePath . fsPath ) ) {
63
55
const yes = "Yes" ;
Original file line number Diff line number Diff line change 1
1
import * as vscode from 'vscode' ;
2
2
import commandExists = require( 'command-exists' ) ;
3
3
import { Octokit } from '@octokit/core' ;
4
+ import * as utils from './utils' ;
4
5
5
6
const octokit = new Octokit ( ) ;
6
7
@@ -15,12 +16,15 @@ function getTerminal(): vscode.Terminal {
15
16
16
17
function cmd ( body : string ) {
17
18
return async ( ) => {
18
- const tt = 'tt' ;
19
+ const wsFolder = utils . fetchWsFolder ( ) ;
20
+ const config = vscode . workspace . getConfiguration ( undefined , wsFolder ) ;
21
+ const tt = config . get < string > ( 'tarantool.ttPath' ) || 'tt' ;
22
+
19
23
commandExists ( `${ tt } ` ) . then ( ( ) => {
20
24
const t = getTerminal ( ) ;
21
25
t . sendText ( `${ tt } ${ body } ` ) ;
22
26
} ) . catch ( function ( ) {
23
- vscode . window . showErrorMessage ( 'TT is not installed ' ) ;
27
+ vscode . window . showErrorMessage ( 'TT is not available. Install it or provide a path to it explicitly in the Tarantool plugin configuration. ' ) ;
24
28
} ) ;
25
29
} ;
26
30
}
Original file line number Diff line number Diff line change
1
+ import * as vscode from 'vscode' ;
2
+
3
+ export function fetchWsFolder ( opts ?: { showWarning ?: boolean } ) : vscode . WorkspaceFolder | null {
4
+ const file = vscode . window . activeTextEditor ?. document . uri . fsPath ;
5
+
6
+ const wsFolders = vscode . workspace . workspaceFolders ;
7
+ if ( ! wsFolders ) {
8
+ if ( opts ?. showWarning ) {
9
+ vscode . window . showWarningMessage ( 'Please, open a project before running this command' ) ;
10
+ }
11
+ return null ;
12
+ }
13
+
14
+ const wsFolder = file ? wsFolders . find ( ( folder ) => file . startsWith ( folder . uri . fsPath ) ) : wsFolders . at ( 0 ) ;
15
+ if ( ! wsFolder ) {
16
+ if ( opts ?. showWarning ) {
17
+ vscode . window . showWarningMessage ( 'Please, open at least one folder within the workspace' ) ;
18
+ }
19
+ return null ;
20
+ }
21
+
22
+ return wsFolder ;
23
+ }
You can’t perform that action at this time.
0 commit comments