File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 1+ [tools ]
2+ python = " 3.8.0"
Original file line number Diff line number Diff line change @@ -130,6 +130,18 @@ describe('Version from file test', () => {
130130 expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [ pythonVersion ] ) ;
131131 }
132132 ) ;
133+ it . each ( [ getVersionInputFromTomlFile , getVersionInputFromFile ] ) (
134+ 'Version from mise mise.tml test' ,
135+ async _fn => {
136+ await io . mkdirP ( tempDir ) ;
137+ const pythonVersionFileName = 'mise.toml' ;
138+ const pythonVersionFilePath = path . join ( tempDir , pythonVersionFileName ) ;
139+ const pythonVersion = '3.8.0' ;
140+ const pythonVersionFileContent = `[tools]\npython = "${ pythonVersion } "` ;
141+ fs . writeFileSync ( pythonVersionFilePath , pythonVersionFileContent ) ;
142+ expect ( _fn ( pythonVersionFilePath ) ) . toEqual ( [ pythonVersion ] ) ;
143+ }
144+ ) ;
133145 it . each ( [ getVersionInputFromTomlFile , getVersionInputFromFile ] ) (
134146 'Version undefined' ,
135147 async _fn => {
Original file line number Diff line number Diff line change @@ -235,15 +235,21 @@ export function getVersionInputFromTomlFile(versionFile: string): string[] {
235235 pyprojectFile = pyprojectFile . replace ( / \r \n / g, '\n' ) ;
236236
237237 const pyprojectConfig = toml . parse ( pyprojectFile ) ;
238- let keys = [ ] ;
238+ let keys : string [ ] = [ ] ;
239239
240240 if ( 'project' in pyprojectConfig ) {
241241 // standard project metadata (PEP 621)
242242 keys = [ 'project' , 'requires-python' ] ;
243- } else {
243+ }
244+ else if ( 'tool' in pyprojectConfig ) {
244245 // python poetry
245246 keys = [ 'tool' , 'poetry' , 'dependencies' , 'python' ] ;
246247 }
248+ else if ( 'tools' in pyprojectConfig ) {
249+ // mise
250+ keys = [ 'tools' , 'python' ]
251+ }
252+
247253 const versions = [ ] ;
248254 const version = extractValue ( pyprojectConfig , keys ) ;
249255 if ( version !== undefined ) {
You can’t perform that action at this time.
0 commit comments