Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d3afba6

Browse filesBrowse files
committed
feat: support reading mise.toml
1 parent 19e4675 commit d3afba6
Copy full SHA for d3afba6

File tree

3 files changed

+22
-2
lines changed
Filter options

3 files changed

+22
-2
lines changed

‎__tests__/data/mise.toml

Copy file name to clipboard
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[tools]
2+
python = "3.8.0"

‎__tests__/utils.test.ts

Copy file name to clipboardExpand all lines: __tests__/utils.test.ts
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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 => {

‎src/utils.ts

Copy file name to clipboardExpand all lines: src/utils.ts
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.