Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bin/gapwise.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { existsSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { spawnSync } from 'node:child_process';
Expand Down Expand Up @@ -159,6 +159,6 @@ export function main(argv = process.argv.slice(2)) {
throw new Error('Usage: gapwise university create|validate|dev|test <id> [--dry-run] [--workspace PATH]\n gapwise data validate|osm <id>');
}

if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
if (process.argv[1] && realpathSync(resolve(process.argv[1])) === fileURLToPath(import.meta.url)) {
try { main(); } catch (error) { console.error(error instanceof Error ? error.message : error); process.exitCode = 1; }
}
14 changes: 13 additions & 1 deletion tests/cli.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { dirname, join, resolve } from 'node:path';
import { spawnSync } from 'node:child_process';
Expand Down Expand Up @@ -36,6 +36,18 @@ test('dry run shows integration and data files without changing the workspace',
} finally { rmSync(workspace, { recursive: true, force: true }); }
});

test('installed bin symlink executes the CLI', () => {
const workspace = fixture();
try {
const installedBin = join(workspace, 'gapwise-bin');
symlinkSync(resolve(import.meta.dirname, '../bin/gapwise.mjs'), installedBin);
const result = spawnSync(installedBin, ['university', 'create', 'example-university', '--dry-run', '--workspace', workspace],
{ encoding: 'utf8' });
assert.equal(result.status, 0, result.stderr);
assert.match(result.stdout, /Dry run for example-university/);
} finally { rmSync(workspace, { recursive: true, force: true }); }
});

test('scaffold creates adapter, manifest, test, and empty campus snapshots', () => {
const workspace = fixture();
try {
Expand Down
Loading