mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-12-02 17:53:47 +08:00
Add layout registration, visual editing, and source generation. Preserve embedded pages and wait for asynchronous layout renderers. Add workspace lint and formatting commands.
33 lines
853 B
JavaScript
33 lines
853 B
JavaScript
import { spawnSync } from 'node:child_process'
|
|
import { statSync } from 'node:fs'
|
|
import { fileURLToPath } from 'node:url'
|
|
import prettier from 'prettier/package.json' with { type: 'json' }
|
|
import { applyLintFixes } from './lint-fix.mjs'
|
|
|
|
const [directory = '.', ...extra] = process.argv.slice(
|
|
process.argv[2] === '--' ? 3 : 2,
|
|
)
|
|
|
|
if (
|
|
extra.length ||
|
|
!statSync(directory, { throwIfNoEntry: false })?.isDirectory()
|
|
) {
|
|
console.error('Usage: pnpm fix [directory]')
|
|
process.exit(1)
|
|
}
|
|
|
|
const lintCode = await applyLintFixes([directory])
|
|
const prettierBin = new URL(
|
|
prettier.bin,
|
|
import.meta.resolve('prettier/package.json'),
|
|
)
|
|
const { error, status } = spawnSync(
|
|
process.execPath,
|
|
[fileURLToPath(prettierBin), '--write', '--', directory],
|
|
{ stdio: 'inherit' },
|
|
)
|
|
|
|
if (error) throw error
|
|
|
|
process.exitCode = (status ?? 1) || lintCode
|