forked from conventional-changelog/standard-version
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(python): add poetry support (#188)
* feat(python): add poetry support * chore: run autoformatter --------- Co-authored-by: Timothy Jones <timothy.l.jones@gmail.com>
- Loading branch information
1 parent
959200c
commit 01f08e9
Showing
6 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const versionExtractRegex = /version[" ]*=[ ]*["'](.*)["']/i; | ||
|
||
const getVersionIndex = function (lines) { | ||
let version; | ||
const lineNumber = lines.findIndex((line) => { | ||
const versionMatcher = line.match(versionExtractRegex); | ||
// if version not found in lines provided, return false | ||
if (versionMatcher == null) { | ||
return false; | ||
} | ||
version = versionMatcher[1]; | ||
return true; | ||
}); | ||
return { version, lineNumber }; | ||
}; | ||
|
||
module.exports.readVersion = function (contents) { | ||
const lines = contents.split('\n'); | ||
const versionIndex = getVersionIndex(lines); | ||
return versionIndex.version; | ||
}; | ||
|
||
module.exports.writeVersion = function (contents, version) { | ||
const lines = contents.split('\n'); | ||
const versionIndex = getVersionIndex(lines); | ||
const versionLine = lines[versionIndex.lineNumber]; | ||
const newVersionLine = versionLine.replace(versionIndex.version, version); | ||
lines[versionIndex.lineNumber] = newVersionLine; | ||
return lines.join('\n'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[tool.poetry] | ||
name = "test" | ||
version = "1.0.0" | ||
description = "" | ||
authors = [] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
|
||
[build-system] | ||
requires = ["poetry>=1"] | ||
build-backend = "poetry.masonry.api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[tool.poetry] | ||
name = "test" | ||
version = "1.1.0" | ||
description = "" | ||
authors = [] | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.8" | ||
|
||
[build-system] | ||
requires = ["poetry>=1"] | ||
build-backend = "poetry.masonry.api" |