-
Notifications
You must be signed in to change notification settings - Fork 797
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65e5708
commit be30936
Showing
6 changed files
with
77 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const stringifyPackage = require('stringify-package') | ||
const detectIndent = require('detect-indent') | ||
const detectNewline = require('detect-newline') | ||
|
||
module.exports.readVersion = function (contents) { | ||
return JSON.parse(contents).version | ||
} | ||
|
||
module.exports.writeVersion = function (contents, version) { | ||
const json = JSON.parse(contents) | ||
let indent = detectIndent(contents).indent | ||
let newline = detectNewline(contents) | ||
json.version = version | ||
return stringifyPackage(json, indent, newline) | ||
} |
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,7 @@ | ||
module.exports.readVersion = function (contents) { | ||
return contents | ||
} | ||
|
||
module.exports.writeVersion = function (_contents, version) { | ||
return version | ||
} |
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 @@ | ||
const REPLACER = /version: "(.*)"/ | ||
|
||
module.exports.readVersion = function (contents) { | ||
return REPLACER.exec(contents)[1] | ||
} | ||
|
||
module.exports.writeVersion = function (contents, version) { | ||
return contents.replace( | ||
REPLACER.exec(contents)[0], | ||
`version: "${version}"` | ||
) | ||
} |
Empty file.