Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: detect the underlying runtime #66

Merged
merged 12 commits into from
Aug 16, 2023
Merged

Conversation

QuiiBz
Copy link
Contributor

@QuiiBz QuiiBz commented Aug 16, 2023

πŸ”— Linked issue

#65

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Port from https://github.com/QuiiBz/detect-runtime to add a new detectRuntime() function, and new isNode, isDeno, and isBun flags.

The list of runtime keys is currently limited to workerd, deno, lagon, netlify, node, bun, edge-light, and fastly because electron, react-native, and edge-routine are not easily detectable.

This PR also updates the Provider Detection section of the README to use the correct provider and providerInfo variables (instead of platform and platformInfo)

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

src/runtimes.ts Outdated Show resolved Hide resolved
src/runtimes.ts Outdated Show resolved Hide resolved
src/runtimes.ts Outdated Show resolved Hide resolved
src/flags.ts Outdated Show resolved Hide resolved
@QuiiBz QuiiBz requested a review from pi0 August 16, 2023 16:13
@codecov
Copy link

codecov bot commented Aug 16, 2023

Codecov Report

Merging #66 (3428b6e) into main (8dca804) will increase coverage by 3.13%.
The diff coverage is 100.00%.

❗ Current head 3428b6e differs from pull request most recent head 851f3aa. Consider uploading reports for the commit 851f3aa to get more accurate results

@@            Coverage Diff             @@
##             main      #66      +/-   ##
==========================================
+ Coverage   82.88%   86.02%   +3.13%     
==========================================
  Files           6        7       +1     
  Lines         263      322      +59     
  Branches       25       29       +4     
==========================================
+ Hits          218      277      +59     
  Misses         42       42              
  Partials        3        3              
Files Changed Coverage Ξ”
src/index.ts 100.00% <100.00%> (ΓΈ)
src/runtimes.ts 100.00% <100.00%> (ΓΈ)

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks πŸ’―

(I made some small changes hope you are happy with them)

@pi0 pi0 merged commit d8a7a98 into unjs:main Aug 16, 2023
Copy link

@paperclover paperclover left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i forgot to press "submit review"

oops

// https://nodejs.org/api/process.html#processrelease
export const isLagon = !!globalThis.__lagon__;
export const isNode = globalThis.process?.release?.name === "node";
export const isBun = globalThis.process?.release?.name === "bun";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i could be mistaken but i believe we updated this property to be "node" due to a compatibility fix of an old package.

use !!globalThis.bun or !!process.versions.bun

@pi0 pi0 mentioned this pull request Aug 16, 2023
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants