Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,59 @@
import {promisify} from 'node:util';
import process from 'node:process';
import childProcess from 'node:child_process';
const execFilePromises = promisify(childProcess.execFile);
export async function systemArchitecture() {
const {arch, platform, env} = process;
// Detect Node.js x64 binary running under Rosetta 2 on a ARM64 Mac.
if (platform === 'darwin' && arch === 'x64') {
const {stdout} = await execFilePromises('sysctl', ['-inq', 'sysctl.proc_translated'], {encoding: 'utf8'});
return stdout.trim() === '1' ? 'arm64' : 'x64';
}
if (arch === 'arm64' || arch === 'x64') {
return arch;
}
if (platform === 'win32' && Object.hasOwn(env, 'PROCESSOR_ARCHITEW6432')) {
return 'x64';
}
if (platform === 'linux') {
const {stdout} = await execFilePromises('getconf', ['LONG_BIT'], {encoding: 'utf8'});
if (stdout.trim() === '64') {
return 'x64';
}
}
return arch;
}
export function systemArchitectureSync() {
const {arch, platform, env} = process;
// Detect Node.js x64 binary running under Rosetta 2 on a ARM64 Mac.
if (platform === 'darwin' && arch === 'x64') {
const stdout = childProcess.execFileSync('sysctl', ['-inq', 'sysctl.proc_translated'], {encoding: 'utf8'});
return stdout.trim() === '1' ? 'arm64' : 'x64';
}
if (arch === 'arm64' || arch === 'x64') {
return arch;
}
if (platform === 'win32' && Object.hasOwn(env, 'PROCESSOR_ARCHITEW6432')) {
return 'x64';
}
if (platform === 'linux') {
const stdout = childProcess.execFileSync('getconf', ['LONG_BIT'], {encoding: 'utf8'});
if (stdout.trim() === '64') {
return 'x64';
}
}
return arch;
}