mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-07-12 22:13:12 +08:00
feat: read engines from package json (#132)
* feat: read engines from package.json closes https://github.com/oven-sh/setup-bun/issues/115 * ci: test for engines package.json * [autofix.ci] apply automated fixes * ci: test for engines package.json --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
34f777aec1
commit
56169ab7b0
16
.github/workflows/test.yml
vendored
16
.github/workflows/test.yml
vendored
@ -90,21 +90,27 @@ jobs:
|
|||||||
- windows-latest
|
- windows-latest
|
||||||
|
|
||||||
file:
|
file:
|
||||||
- name: package.json (bun@1.1.0)
|
- name: package.json (packageManager bun@1.1.0)
|
||||||
file: package.json
|
file: package.json
|
||||||
run: |
|
run: |
|
||||||
echo "$(jq '. += {"packageManager": "bun@1.1.0"}' package.json)" > package.json
|
echo "$(jq '. += {"packageManager": "bun@1.1.0"}' package.json)" > package.json
|
||||||
|
|
||||||
- name: /foo/package.json (bun@1.1.0)
|
- name: foo/package.json (packageManager bun@1.1.0)
|
||||||
file: /foo/package.json
|
file: foo/package.json
|
||||||
run: |
|
run: |
|
||||||
echo "$(jq '. += {"packageManager": "bun@1.1.0"}' package.json)" > /foo/package.json
|
mkdir -p foo
|
||||||
|
echo "$(jq '. += {"packageManager": "bun@1.1.0"}' package.json)" > foo/package.json
|
||||||
|
|
||||||
- name: package.json (yarn@bun@1.1.0)
|
- name: package.json (packageManager yarn@bun@1.1.0)
|
||||||
file: package.json
|
file: package.json
|
||||||
run: |
|
run: |
|
||||||
echo "$(jq '. += {"packageManager": "yarn@bun@1.1.0"}' package.json)" > package.json
|
echo "$(jq '. += {"packageManager": "yarn@bun@1.1.0"}' package.json)" > package.json
|
||||||
|
|
||||||
|
- name: package.json (engines bun@1.1.0)
|
||||||
|
file: package.json
|
||||||
|
run: |
|
||||||
|
echo "$(jq '.engines = {"bun": "1.1.0"}' package.json)" > package.json
|
||||||
|
|
||||||
- name: .tool-versions (bun 1.1.0)
|
- name: .tool-versions (bun 1.1.0)
|
||||||
file: .tool-versions
|
file: .tool-versions
|
||||||
run: echo "bun 1.1.0" > .tool-versions
|
run: echo "bun 1.1.0" > .tool-versions
|
||||||
|
72
dist/setup/index.js
generated
vendored
72
dist/setup/index.js
generated
vendored
File diff suppressed because one or more lines are too long
@ -28,8 +28,10 @@ export function addExtension(path: string, ext: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const FILE_VERSION_READERS = {
|
const FILE_VERSION_READERS = {
|
||||||
"package.json": (content: string) =>
|
"package.json": (content: string) => {
|
||||||
JSON.parse(content).packageManager?.split("bun@")?.[1],
|
const pkg = JSON.parse(content);
|
||||||
|
return pkg.packageManager?.split("bun@")?.[1] ?? pkg.engines?.bun;
|
||||||
|
},
|
||||||
".tool-versions": (content: string) =>
|
".tool-versions": (content: string) =>
|
||||||
content.match(/^bun\s*(?<version>.*?)$/m)?.groups?.version,
|
content.match(/^bun\s*(?<version>.*?)$/m)?.groups?.version,
|
||||||
".bumrc": (content: string) => content, // https://github.com/owenizedd/bum
|
".bumrc": (content: string) => content, // https://github.com/owenizedd/bum
|
||||||
|
Loading…
x
Reference in New Issue
Block a user