-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to parse values at build time
- Loading branch information
1 parent
a0c31bd
commit e06ebc8
Showing
5 changed files
with
52 additions
and
52 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 |
---|---|---|
@@ -1,25 +1,8 @@ | ||
const version = process.env.MUI_PACKAGE_VERSION || null; | ||
export const version = process.env.MUI_VERSION; | ||
export const major = Number(process.env.MUI_MAJOR_VERSION); | ||
export const minor = Number(process.env.MUI_MINOR_VERSION); | ||
export const patch = Number(process.env.MUI_PATCH_VERSION); | ||
export const preReleaseLabel = process.env.MUI_PRERELEASE_LABEL || null; | ||
export const preReleaseNumber = Number(process.env.MUI_PRERELEASE_NUMBER) || null; | ||
|
||
let versionNumber: string | null = null; | ||
let preReleaseInfo: string | null = null; | ||
|
||
if (version) { | ||
[versionNumber, preReleaseInfo] = version.split('-'); | ||
} | ||
|
||
let destructuredVersion: number[] | null[] = [null, null, null]; | ||
let destructuredPreReleaseInfo: [string, number] | null[] = [null, null]; | ||
|
||
if (versionNumber) { | ||
destructuredVersion = versionNumber.split('.').map(Number); | ||
} | ||
|
||
if (preReleaseInfo) { | ||
destructuredPreReleaseInfo = [preReleaseInfo.split('.')[0], Number(preReleaseInfo.split('.')[1])]; | ||
} | ||
|
||
const [major, minor, patch] = destructuredVersion; | ||
const [preReleaseLabel, preReleaseNumber] = destructuredPreReleaseInfo; | ||
|
||
export { version, major, minor, patch, preReleaseLabel, preReleaseNumber }; | ||
export default 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,8 @@ | ||
const version = process.env.MUI_PACKAGE_VERSION || null; | ||
export const version = process.env.MUI_VERSION; | ||
export const major = Number(process.env.MUI_MAJOR_VERSION); | ||
export const minor = Number(process.env.MUI_MINOR_VERSION); | ||
export const patch = Number(process.env.MUI_PATCH_VERSION); | ||
export const preReleaseLabel = process.env.MUI_PRERELEASE_LABEL || null; | ||
export const preReleaseNumber = Number(process.env.MUI_PRERELEASE_NUMBER) || null; | ||
|
||
let versionNumber: string | null = null; | ||
let preReleaseInfo: string | null = null; | ||
|
||
if (version) { | ||
[versionNumber, preReleaseInfo] = version.split('-'); | ||
} | ||
|
||
let destructuredVersion: number[] | null[] = [null, null, null]; | ||
let destructuredPreReleaseInfo: [string, number] | null[] = [null, null]; | ||
|
||
if (versionNumber) { | ||
destructuredVersion = versionNumber.split('.').map(Number); | ||
} | ||
|
||
if (preReleaseInfo) { | ||
destructuredPreReleaseInfo = [preReleaseInfo.split('.')[0], Number(preReleaseInfo.split('.')[1])]; | ||
} | ||
|
||
const [major, minor, patch] = destructuredVersion; | ||
const [preReleaseLabel, preReleaseNumber] = destructuredPreReleaseInfo; | ||
|
||
export { version, major, minor, patch, preReleaseLabel, preReleaseNumber }; | ||
export default 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