@@ -3,7 +3,7 @@ import { TestConfigurationManager } from '../common/testConfigurationManager';
33import * as fs from 'fs' ;
44import * as path from 'path' ;
55import { Installer , Product } from '../../common/installer' ;
6-
6+
77export class ConfigurationManager extends TestConfigurationManager {
88 public enable ( ) : Thenable < any > {
99 const pythonConfig = vscode . workspace . getConfiguration ( 'python' ) ;
@@ -14,42 +14,36 @@ export class ConfigurationManager extends TestConfigurationManager {
1414 return pythonConfig . update ( 'unitTest.nosetestsEnabled' , false ) ;
1515 }
1616
17- private static configFilesExist ( rootDir : string ) : Promise < boolean > {
18- const promises = [
19- new Promise < boolean > ( resolve => {
20- fs . exists ( path . join ( rootDir , '.noserc' ) , exists => { resolve ( true ) ; } ) ;
21- } ) ,
22- new Promise < boolean > ( resolve => {
23- fs . exists ( path . join ( rootDir , 'nose.cfg' ) , exists => { resolve ( true ) ; } ) ;
24- } ) ] ;
17+ private static configFilesExist ( rootDir : string ) : Promise < string [ ] > {
18+ const promises = [ '.noserc' , 'nose.cfg' ] . map ( cfg => {
19+ return new Promise < string > ( resolve => {
20+ fs . exists ( path . join ( rootDir , cfg ) , exists => { resolve ( exists ? cfg : '' ) ; } ) ;
21+ } ) ;
22+ } ) ;
2523 return Promise . all ( promises ) . then ( values => {
26- return values . some ( exists => exists ) ;
24+ return values . filter ( exists => exists . length > 0 ) ;
2725 } ) ;
2826 }
2927 public configure ( rootDir : string ) : Promise < any > {
3028 const args = [ ] ;
3129 const configFileOptionLabel = 'Use existing config file' ;
32- const options : vscode . QuickPickItem [ ] = [ ] ;
3330 let installer = new Installer ( this . outputChannel ) ;
34- return ConfigurationManager . configFilesExist ( rootDir ) . then ( configExists => {
35- if ( configExists ) {
36- options . push ( {
37- label : configFileOptionLabel ,
38- description : '.noserc or nose.cfg'
39- } ) ;
40- }
41- } ) . then ( ( ) => {
42- return this . getTestDirs ( rootDir ) ;
43- } ) . then ( subDirs => {
44- return this . selectTestDir ( rootDir , subDirs , options ) ;
45- } ) . then ( testDir => {
46- if ( typeof testDir === 'string' && testDir !== configFileOptionLabel ) {
47- args . push ( testDir ) ;
31+ return ConfigurationManager . configFilesExist ( rootDir ) . then ( configFiles => {
32+ if ( configFiles . length > 0 ) {
33+ return Promise . resolve ( ) ;
4834 }
35+
36+ return this . getTestDirs ( rootDir ) . then ( subDirs => {
37+ return this . selectTestDir ( rootDir , subDirs ) ;
38+ } ) . then ( testDir => {
39+ if ( typeof testDir === 'string' && testDir !== configFileOptionLabel ) {
40+ args . push ( testDir ) ;
41+ }
42+ } ) ;
4943 } ) . then ( ( ) => {
5044 return installer . isProductInstalled ( Product . nosetest ) ;
5145 } ) . then ( installed => {
52- if ( ! installed ) {
46+ if ( ! installed ) {
5347 return installer . installProduct ( Product . nosetest ) ;
5448 }
5549 } ) . then ( ( ) => {
0 commit comments