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
88
99## [ Unreleased]
1010
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+
1116### Changed
1217
1318- Now the extension automatically setups Tarantool annotations without need to
Original file line number Diff line number Diff line change 7575 ],
7676 "url" : " https://download.tarantool.org/tarantool/schema/config.schema.json"
7777 }
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+ }
7989 },
8090 "scripts" : {
8191 "vscode:prepublish" : " npm run package" ,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import * as tt from './tt';
33import * as fs from 'fs' ;
44import * as os from 'os' ;
55import * as _ from 'lodash' ;
6+ import * as utils from './utils' ;
67
78const annotationsPaths = [
89 __dirname + "/Library" ,
@@ -43,21 +44,12 @@ async function initGlobalEmmyrc() {
4344}
4445
4546async 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 ;
5648 if ( ! wsPath ) {
57- vscode . window . showWarningMessage ( 'Please, open at least one folder within the workspace' ) ;
5849 return ;
5950 }
6051
52+ const wsedit = new vscode . WorkspaceEdit ( ) ;
6153 const filePath = vscode . Uri . file ( `${ wsPath } /${ emmyrcFile } ` ) ;
6254 if ( fs . existsSync ( filePath . fsPath ) ) {
6355 const yes = "Yes" ;
Original file line number Diff line number Diff line change 11import * as vscode from 'vscode' ;
22import commandExists = require( 'command-exists' ) ;
33import { Octokit } from '@octokit/core' ;
4+ import * as utils from './utils' ;
45
56const octokit = new Octokit ( ) ;
67
@@ -15,12 +16,15 @@ function getTerminal(): vscode.Terminal {
1516
1617function cmd ( body : string ) {
1718 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+
1923 commandExists ( `${ tt } ` ) . then ( ( ) => {
2024 const t = getTerminal ( ) ;
2125 t . sendText ( `${ tt } ${ body } ` ) ;
2226 } ) . 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. ' ) ;
2428 } ) ;
2529 } ;
2630}
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