aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bun.js/bindings/Process.cpp31
-rw-r--r--src/cli/upgrade_command.zig9
-rw-r--r--test/bun.js/process.test.js9
3 files changed, 49 insertions, 0 deletions
diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp
index d9a908541..1cb61c3a6 100644
--- a/src/bun.js/bindings/Process.cpp
+++ b/src/bun.js/bindings/Process.cpp
@@ -272,6 +272,34 @@ static JSC_DEFINE_HOST_FUNCTION(Process_functionChdir,
return JSC::JSValue::encode(result);
}
+extern "C" const char* Bun__githubURL;
+
+JSC_DEFINE_CUSTOM_GETTER(Process_getterRelease, (JSGlobalObject * globalObject, EncodedJSValue thisValue, PropertyName))
+{
+ auto& vm = globalObject->vm();
+
+ auto* release = JSC::constructEmptyObject(globalObject);
+ release->putDirect(vm, Identifier::fromString(vm, "name"_s), jsString(vm, WTF::String("bun"_s)), 0);
+ release->putDirect(vm, Identifier::fromString(vm, "lts"_s), jsBoolean(false), 0);
+ release->putDirect(vm, Identifier::fromString(vm, "sourceUrl"_s), jsString(vm, WTF::String(Bun__githubURL, strlen(Bun__githubURL))), 0);
+ release->putDirect(vm, Identifier::fromString(vm, "headersUrl"_s), jsEmptyString(vm), 0);
+ release->putDirect(vm, Identifier::fromString(vm, "libUrl"_s), jsEmptyString(vm), 0);
+
+ return JSValue::encode(release);
+}
+
+JSC_DEFINE_CUSTOM_SETTER(Process_setterRelease,
+ (JSC::JSGlobalObject * globalObject, JSC::EncodedJSValue thisValue,
+ JSC::EncodedJSValue value, JSC::PropertyName))
+{
+ JSC::VM& vm = globalObject->vm();
+
+ JSC::JSObject* thisObject = JSC::jsDynamicCast<JSC::JSObject*>(JSValue::decode(thisValue));
+ thisObject->putDirect(vm, JSC::Identifier::fromString(vm, "release"_s), JSValue::decode(value), 0);
+
+ return true;
+}
+
void Process::finishCreation(JSC::VM& vm)
{
Base::finishCreation(vm);
@@ -368,6 +396,9 @@ void Process::finishCreation(JSC::VM& vm)
hrtime->putDirect(vm, JSC::Identifier::fromString(vm, "bigint"_s), hrtimeBigInt);
this->putDirect(this->vm(), JSC::Identifier::fromString(this->vm(), "hrtime"_s), hrtime);
+
+ this->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "release"_s)),
+ JSC::CustomGetterSetter::create(vm, Process_getterRelease, Process_setterRelease), 0);
}
const JSC::ClassInfo Process::s_info = { "Process"_s, &Base::s_info, nullptr, nullptr,
diff --git a/src/cli/upgrade_command.zig b/src/cli/upgrade_command.zig
index 05d8a9cd6..9aa20875b 100644
--- a/src/cli/upgrade_command.zig
+++ b/src/cli/upgrade_command.zig
@@ -92,9 +92,18 @@ pub const Version = struct {
const current_version: string = "bun-v" ++ Global.package_json_version;
+ pub export const Bun__githubURL: [*:0]const u8 = std.fmt.comptimePrint("https://github.com/oven-sh/bun/release/bun-v{s}/{s}", .{
+ Global.package_json_version,
+ zip_filename,
+ });
+
pub fn isCurrent(this: Version) bool {
return strings.eqlComptime(this.tag, current_version);
}
+
+ comptime {
+ _ = Bun__githubURL;
+ }
};
pub const UpgradeCheckerThread = struct {
diff --git a/test/bun.js/process.test.js b/test/bun.js/process.test.js
index 5131d3b28..3ca93c983 100644
--- a/test/bun.js/process.test.js
+++ b/test/bun.js/process.test.js
@@ -66,3 +66,12 @@ it("process.hrtime.bigint()", () => {
const end = process.hrtime.bigint();
expect(end > start).toBe(true);
});
+
+it("process.release", () => {
+ expect(process.release.name).toBe("bun");
+ expect(process.release.sourceUrl).toBe(
+ `https://github.com/oven-sh/bun/release/bun-v${process.versions.bun}/bun-${
+ process.platform
+ }-${{ arm64: "aarch64", x64: "x64" }[process.arch] || process.arch}.zip`
+ );
+});