diff --git a/packages/autofmt/autofmt.js b/packages/autofmt/autofmt.js index 0e87b07bcc98ea32558fc048bde321aaa1e361bb..59b144b48b51a965dfd9c79005bdfd00dec2b445 100755 --- a/packages/autofmt/autofmt.js +++ b/packages/autofmt/autofmt.js @@ -69,13 +69,6 @@ const formatters = { cmd: ["treefmt", "--", "$files"], stdin: (file) => ["treefmt", "--stdin", file], }, - // -- web ecosystem -- - deno: { - languages: ["javascript", "markdown", "json", "yaml", "html", "css"], - files: ["deno.json", "deno.jsonc"], - cmd: ["deno", "fmt", "--", "$files"], - stdin: (file) => ["deno", "fmt", "--ext", path.extname(file).slice(1), "-"], - }, vp: { languages: ["javascript", "markdown", "json", "yaml", "mdx", "html", "css"], mustMatchFile: true, @@ -88,6 +81,13 @@ const formatters = { file, ], }, + // -- web ecosystem -- + deno: { + languages: ["javascript", "markdown", "json", "yaml", "html", "css"], + files: ["deno.json", "deno.jsonc"], + cmd: ["deno", "fmt", "--", "$files"], + stdin: (file) => ["deno", "fmt", "--ext", path.extname(file).slice(1), "-"], + }, oxfmt: { languages: ["javascript", "markdown", "json", "yaml", "mdx", "html", "css"], mustMatchFile: true, @@ -168,66 +168,50 @@ const formatters = { }; // -- cli -- -function cli() { - if (!fs.globSync) { - console.error(`error: autofmt must be run with Node.js v22 or newer`); - process.exit(1); - } - const [, bin, ...argv] = process.argv; - let inputs = []; - let globalExclude = []; - let gitignore = true; - let dryRun = false; - let stdio = null; - let excludes = [".git"]; - while (argv.length > 0) { - const arg = argv.shift(); - if (arg === "-h" || arg === "--help") cliUsage(); - else if (arg === "--no-gitignore") gitignore = false; - else if (arg === "--dry-run") dryRun = true; - else if (arg.match(/^--stdio=./)) { - if (stdio) { - console.error("error: can only pass --stdio once"); - cliUsage(); - } - stdio = arg.slice("--stdio=".length); - } else if (arg === "--stdio") { - const value = argv.shift(); - if (!value) { - console.error("error: missing value for --stdio"); - cliUsage(); - } - if (stdio) { - console.error("error: can only pass --stdio once"); - cliUsage(); - } - stdio = value; - } else if (arg.match(/^--exclude=./)) { - excludes.push(arg.slice("--exclude=".length)); - } else if (arg === "--") { - inputs.push(...argv); - break; - } else if (arg.startsWith("-")) { - console.error("error: unknown option " + JSON.stringify(arg)); - cliUsage(); - } else inputs.push(arg); - } - if (inputs.length === 0 && !stdio) cliUsage(); - if (stdio && inputs.length > 0) { - console.error("error: stdio mode only operates on one file"); - process.exit(1); - } - // -- disable warnings -- - const { emit: originalEmit } = process; - const warnings = ["ExperimentalWarning"]; - process.emit = function (event, error) { - return event === "warning" && warnings.includes(error.name) - ? false - : originalEmit.apply(process, arguments); - }; +if (!fs.globSync) { + console.error(`error: autofmt must be run with Node.js v22 or newer`); + process.exit(1); } - -function cliUsage() { +const [, bin, ...argv] = process.argv; +let inputs = []; +let globalExclude = []; +let gitignore = true; +let dryRun = false; +let stdio = null; +let excludes = [".git"]; +while (argv.length > 0) { + const arg = argv.shift(); + if (arg === "-h" || arg === "--help") usage(); + else if (arg === "--no-gitignore") gitignore = false; + else if (arg === "--dry-run") dryRun = true; + else if (arg.match(/^--stdio=./)) { + if (stdio) { + console.error("error: can only pass --stdio once"); + usage(); + } + stdio = arg.slice("--stdio=".length); + } else if (arg === "--stdio") { + const value = argv.shift(); + if (!value) { + console.error("error: missing value for --stdio"); + usage(); + } + if (stdio) { + console.error("error: can only pass --stdio once"); + usage(); + } + stdio = value; + } else if (arg.match(/^--exclude=./)) { + excludes.push(arg.slice("--exclude=".length)); + } else if (arg === "--") { + inputs.push(...argv); + break; + } else if (arg.startsWith("-")) { + console.error("error: unknown option " + JSON.stringify(arg)); + usage(); + } else inputs.push(arg); +} +function usage() { const exe = path.basename(bin); console.error(`usage: ${exe} [...files or directories]`); console.error(``); @@ -244,9 +228,21 @@ function cliUsage() { console.error(``); process.exit(1); } - -export function autofmt({ files, progress }) { +if (inputs.length === 0 && !stdio) usage(); +if (stdio && inputs.length > 0) { + console.error("error: stdio mode only operates on one file"); + process.exit(1); } +const { sep } = path; + +// -- disable warnings -- +const { emit: originalEmit } = process; +const warnings = ["ExperimentalWarning"]; +process.emit = function (event, error) { + return event === "warning" && warnings.includes(error.name) + ? false + : originalEmit.apply(process, arguments); +}; // -- vars -- const extToLanguage = Object.fromEntries( @@ -355,7 +351,6 @@ const syncEnd = "\u001B[?2026l"; let buffer = ""; let statusVisible = false; const tty = process.stderr.isTTY; - function writeStatus() { if (!tty) return; clearStatus(); @@ -655,7 +650,6 @@ function escapeGlob(str) { import * as child_process from "node:child_process"; import * as fs from "node:fs"; import * as path from "node:path"; -import { sep } from "node:path"; import * as readline from "node:readline"; import * as events from "node:events"; import process from "node:process"; diff --git a/users/clover/home.nix b/users/clover/home.nix index 7e413bb4c3b2119ee41154823fb239c50d796f50..7637bdb8d2a4946672daa3fe07d273d03e5d607d 100644 --- a/users/clover/home.nix +++ b/users/clover/home.nix @@ -10,6 +10,9 @@ in { home = { stateVersion = "23.05"; # Please read the comment before changing. + sessionPath = [ + "$HOME/.vite-plus/bin" + ]; packages = with pkgs; let