27 lines
964 B
JavaScript
27 lines
964 B
JavaScript
/**
|
|
* Ensures built /bin/help embeds the same sorted command list as commands.mjs.
|
|
* Run after `npm run build -w bare-os-coreutils` (root pretest).
|
|
*/
|
|
import { readFile } from 'node:fs/promises'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
import test from 'brittle'
|
|
import {
|
|
COREUTILS_COMMANDS,
|
|
HELP_DELEGATED_COMMANDS
|
|
} from '../lib/commands.mjs'
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
const helpBin = path.join(__dirname, '../../../kernel/bin/help')
|
|
|
|
test('built help BARE_OS_HELP_BIN_SPACED matches sorted COREUTILS + delegated', async (t) => {
|
|
const src = await readFile(helpBin, 'utf8')
|
|
const m = src.match(/var BARE_OS_HELP_BIN_SPACED = "([^"]*)"/)
|
|
t.ok(m, 'help binary should contain injected BARE_OS_HELP_BIN_SPACED')
|
|
const embedded = m[1].replace(/\\n/g, '\n')
|
|
const expected = [...COREUTILS_COMMANDS, ...HELP_DELEGATED_COMMANDS]
|
|
.sort()
|
|
.join(' ')
|
|
t.is(embedded, expected)
|
|
})
|