This repository has been archived by the owner on Jan 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Francisco Javier Ribó Labrador <elribonazo@gmail.com>
- Loading branch information
1 parent
b3b9446
commit db61623
Showing
3 changed files
with
51 additions
and
2 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,49 @@ | ||
const fs = require('fs'); | ||
|
||
function findPackageVersion(packageName) { | ||
try { | ||
// Read the package.json file | ||
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf-8')); | ||
|
||
// Check if the package is in the dependencies | ||
if (packageJson.peerDependencies && packageJson.peerDependencies[packageName]) { | ||
return packageJson.peerDependencies[packageName]; | ||
} else { | ||
return undefined; // Package not found | ||
} | ||
} catch (error) { | ||
console.error('Error reading or parsing package.json:', error); | ||
return undefined; | ||
} | ||
} | ||
|
||
function updateReadme(version) { | ||
const readmeFilePath = 'README.md'; | ||
|
||
try { | ||
// Read the content of the README.md file | ||
let readmeContent = fs.readFileSync(readmeFilePath, 'utf-8').split('\n'); | ||
|
||
// Check if there are at least 4 lines in the file | ||
if (readmeContent.length >= 4) { | ||
// Replace the 4th line with "123" | ||
readmeContent[3] = `This package is compatible with Atala Prism Wallet SDK v${version.slice(1)}`; | ||
|
||
// Join the lines back together | ||
readmeContent = readmeContent.join('\n'); | ||
|
||
// Write the modified content back to the README.md file | ||
fs.writeFileSync(readmeFilePath, readmeContent, 'utf-8'); | ||
console.log('README.md updated successfully.'); | ||
} else { | ||
console.log('README.md does not have at least 4 lines.'); | ||
} | ||
} catch (error) { | ||
console.error('Error reading or updating README.md:', error); | ||
} | ||
} | ||
|
||
|
||
const packageNameToFind = '@input-output-hk/atala-prism-wallet-sdk'; // Replace with the package name you want to find | ||
const packageVersion = findPackageVersion(packageNameToFind); | ||
updateReadme(packageVersion) |