File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as vscode from 'vscode' ;
22import * as settings from './configSettings' ;
3+ import { createDeferred , isNotInstalledError } from './helpers' ;
4+ import { execPythonFile } from './utils' ;
35
46export enum Product {
57 pytest ,
@@ -133,10 +135,36 @@ export class Installer {
133135 Installer . terminal . sendText ( installScript ) ;
134136 Installer . terminal . show ( false ) ;
135137 }
138+
139+ isProductInstalled ( product : Product ) : Promise < boolean > {
140+ return isProductInstalled ( product ) ;
141+ }
136142}
137143
138144export function disableLinter ( product : Product ) {
139145 const pythonConfig = vscode . workspace . getConfiguration ( 'python' ) ;
140146 const settingToDisable = SettingToDisableProduct . get ( product ) ;
141147 pythonConfig . update ( settingToDisable , false ) ;
148+ }
149+
150+ function isPyTestInstalled ( ) : Promise < boolean > {
151+ const def = createDeferred < boolean > ( ) ;
152+ execPythonFile ( 'py.test' , [ '--version' ] , vscode . workspace . rootPath , false )
153+ . then ( ( ) => {
154+ def . resolve ( true ) ;
155+ } ) . catch ( reason => {
156+ if ( isNotInstalledError ( reason ) ) {
157+ def . resolve ( false ) ;
158+ }
159+ else {
160+ def . resolve ( true ) ;
161+ }
162+ } ) ;
163+ return def . promise ;
164+ }
165+ function isProductInstalled ( product : Product ) : Promise < boolean > {
166+ if ( product === Product . pytest ) {
167+ return isPyTestInstalled ( ) ;
168+ }
169+ throw new Error ( 'Not supported' ) ;
142170}
You can’t perform that action at this time.
0 commit comments