-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(packages): update to latest non-breaking versions * chore(packages): update to latest breaking versions
- Loading branch information
1 parent
d5a1f51
commit e703104
Showing
3 changed files
with
925 additions
and
893 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
const packageName = 'eslint'; | ||
|
||
const output = ` | ||
Legend: production dependency, optional only, dev only | ||
@gitignored/web /home/gervin/Documents/programming/node/web/dynamic/gitignored/apps/web | ||
devDependencies: | ||
@typescript-eslint/eslint-plugin 7.16.1 | ||
└── eslint 8.57.0 peer | ||
@typescript-eslint/parser 7.16.1 | ||
└── eslint 8.57.0 peer | ||
eslint 8.57.0 | ||
eslint-plugin-jsx-a11y 6.9.0 | ||
└── eslint 8.57.0 peer | ||
eslint-plugin-react 7.35.0 | ||
└── eslint 8.57.0 peer | ||
`; | ||
|
||
const parse = (output: string, packageName: string) => { | ||
const lines = output.split('\n'); | ||
|
||
const kind = lines.at(0) === 'devDependencies:' ? '-D' : ''; | ||
|
||
const expression = new RegExp( | ||
`^${packageName} ${Array.from({ length: 3 }, () => '\\d+').join('\\.')}$` | ||
); | ||
|
||
const package = lines.find((line) => { | ||
return line.match(expression); | ||
}); | ||
|
||
if (!package) { | ||
throw new Error(`Package ${packageName} not found`); | ||
} | ||
|
||
const packageWithVersion = package.replace(' ', '@^'); | ||
|
||
return packageWithVersion; | ||
}; | ||
|
||
console.log(parse(output, packageName)); |
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
Oops, something went wrong.