@agametis/create-app-for-fm
Version:
Tool for selecting a starter project for FileMaker applications
38 lines (30 loc) • 1.35 kB
JavaScript
import { execFile } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { dirname, resolve } from 'node:path';
// Detect global install across npm versions/environments
const npmGlobalFlag = process.env.npm_config_global === 'true';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const prefix = process.env.npm_config_prefix || '';
// Heuristics: global installs live under .../lib/node_modules on unix-like
const pathLooksGlobal = /[\\\/]lib[\\\/]node_modules[\\\/]/.test(__dirname) ||
(prefix && (__dirname.startsWith(prefix)));
const isGlobal = npmGlobalFlag || pathLooksGlobal;
if (isGlobal) {
console.log('\n@agametis/create-app-for-fm installed globally.');
console.log('Tip: run "create-app-for-fm --help" to see usage.\n');
// Best-effort: show built-in help after install when interactive
const isTty = process.stdout && process.stdout.isTTY;
const isCI = Boolean(process.env.CI);
if (isTty && !isCI) {
try {
const cliPath = resolve(__dirname, '..', 'src', 'cli.js');
execFile(process.execPath, [cliPath, '--help'], { stdio: 'inherit' }, (err) => {
// Ignore any errors here; this is best-effort only
});
} catch {
// Silently ignore; postinstall should never fail installation
}
}
}