getPlatform (platform.ts)

nanoclaw-railway · infra, platform-detection, dev-tools

Cross-platform detection utilities for NanoClaw setup. /

// Source: https://github.com/arnaudjnn/nanoclaw-railway | License: MIT | Copyright 2026 Gavriel
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Cross-platform detection utilities for NanoClaw setup.
 */
import { execSync } from 'child_process';
import fs from 'fs';
import os from 'os';

export type Platform = 'macos' | 'linux' | 'unknown';
export type ServiceManager = 'launchd' | 'systemd' | 'none';

export function getPlatform(): Platform {
  const platform = os.platform();
  if (platform === 'darwin') return 'macos';
  if (platform === 'linux') return 'linux';
  return 'unknown';
}

export function isWSL(): boolean {
  if (os.platform() !== 'linux') return false;
  try {
    const release = fs.readFileSync('/proc/version', 'utf-8').toLowerCase();
    return relea

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key