-
Notifications
You must be signed in to change notification settings - Fork 24
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
Showing
5 changed files
with
31 additions
and
24 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 |
---|---|---|
@@ -1,24 +1,13 @@ | ||
import * as fs from 'node:fs' | ||
import * as path from 'node:path' | ||
|
||
const getPackageVersion = (): string => { | ||
const packageJsonPath = path.resolve(__dirname, '../examples/package.json') | ||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) | ||
return packageJson.dependencies['sora-js-sdk'].replace('^', '') | ||
} | ||
|
||
// バージョン比較用のヘルパー関数を追加 | ||
export const isVersionGreaterThanOrEqual = (version: string): boolean => { | ||
const packageVersion = getPackageVersion() | ||
|
||
export const isVersionGreaterThanOrEqual = (packageVersion: string, version: string): boolean => { | ||
const v1Parts = packageVersion.split('.').map(Number) | ||
const v2Parts = version.split('.').map(Number) | ||
|
||
for (let i = 0; i < Math.max(v1Parts.length, v2Parts.length); i++) { | ||
const v1 = v1Parts[i] || 0 | ||
const v2 = v2Parts[i] || 0 | ||
if (v1 < v2) return true | ||
if (v1 > v2) return false | ||
if (v1 > v2) return true | ||
if (v1 < v2) return false | ||
} | ||
return true | ||
} |
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