"rambda",
"Recurrency",
"RFID",
+ "runtimes",
"shutdowning",
"sonarlint",
"SRPC",
"tsdoc",
"VCAP",
"webui",
+ "workerd",
"workerset"
]
}
// eslint-disable-next-line n/no-unpublished-import
import { satisfies } from 'semver'
+import { runtime, runtimes } from './utils/runtime.js'
+
const packageJson = JSON.parse(readFileSync('./package.json', 'utf8'))
/**
}
}
-checkNodeVersion()
+switch (runtime) {
+ case runtimes.node:
+ checkNodeVersion()
+ break
+ case runtimes.bun:
+ case runtimes.deno:
+ case runtimes.workerd:
+ case runtimes.browser:
+ default:
+ console.error(chalk.red(`Unsupported ${runtime} runtime detected`))
+ break
+}
},
"scripts": {
"prepare": "node prepare.js",
- "build-requirements": "node --no-warnings build-requirements.js",
+ "build-requirements": "node build-requirements.js",
"start": "pnpm build && cross-env NODE_ENV=production node dist/start.js",
"start:dev": "pnpm build:dev && cross-env NODE_ENV=development node --enable-source-maps dist/start.js",
"start:dev:debug": "pnpm build:dev && cross-env NODE_ENV=development node --enable-source-maps --inspect dist/start.js",
sleep,
validateUUID
} from '../../src/utils/Utils.js'
+import { runtime, runtimes } from '../../utils/runtime.js'
await describe('Utils test suite', async () => {
await it('Verify generateUUID()/validateUUID()', () => {
const date = new Date()
expect(clone(date)).toStrictEqual(date)
expect(clone(date) === date).toBe(false)
- if (satisfies(version, '>=21.0.0')) {
+ if (runtime === runtimes.node && satisfies(version, '>=17.0.0')) {
const url = new URL('https://domain.tld')
expect(() => clone(url)).toThrowError(new Error('Cannot clone object of unsupported type.'))
}
--- /dev/null
+export const runtimes = {
+ bun: 'bun',
+ deno: 'deno',
+ node: 'node',
+ workerd: 'workerd',
+ browser: 'browser'
+}
+
+const isBun = !!globalThis.Bun || !!globalThis.process?.versions?.bun
+const isDeno = !!globalThis.Deno
+const isNode = globalThis.process?.release?.name === 'node'
+// eslint-disable-next-line n/no-unsupported-features/node-builtins
+const isWorkerd = globalThis.navigator?.userAgent === 'Cloudflare-Workers'
+// eslint-disable-next-line n/no-unsupported-features/node-builtins
+const isBrowser = !!globalThis.navigator
+
+export const runtime = (() => {
+ if (isBun) return runtimes.bun
+ if (isDeno) return runtimes.deno
+ if (isNode) return runtimes.node
+ if (isWorkerd) return runtimes.workerd
+ if (isBrowser) return runtimes.browser
+
+ return 'unknown'
+})()