UNPKG

@bomb.sh/tools

Version:

The internal dev, build, and lint CLI for Bombshell projects

1 lines • 1.41 kB
{"version":3,"file":"format.mjs","names":[],"sources":["../../src/commands/format.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { fileURLToPath } from 'node:url';\nimport { x } from 'tinyexec';\nimport type { CommandContext } from '../context.ts';\nimport { local } from '../utils.ts';\n\nconst config = fileURLToPath(new URL('../../oxfmtrc.json', import.meta.url));\n\nexport async function format(ctx: CommandContext) {\n\t// oxfmt resolves `ignorePatterns` relative to the config file, which lives in this\n\t// package, so pass them as excludes to apply them to the project being formatted.\n\tconst { ignorePatterns = [] }: { ignorePatterns?: string[] } = JSON.parse(\n\t\tawait readFile(config, 'utf-8'),\n\t);\n\tconst excludes = ignorePatterns.map((pattern) => `!${pattern}`);\n\tconst result = x(local('oxfmt'), ['-c', config, ...ctx.args, ...excludes]);\n\n\tfor await (const line of result) {\n\t\tconsole.info(line);\n\t}\n\tif (result.exitCode) process.exit(result.exitCode);\n}\n"],"mappings":";;;;;AAMA,MAAM,SAAS,cAAc,IAAI,IAAI,sBAAsB,OAAO,KAAK,GAAG,CAAC;AAE3E,eAAsB,OAAO,KAAqB;CAGjD,MAAM,EAAE,iBAAiB,CAAC,MAAqC,KAAK,MACnE,MAAM,SAAS,QAAQ,OAAO,CAC/B;CACA,MAAM,WAAW,eAAe,KAAK,YAAY,IAAI,SAAS;CAC9D,MAAM,SAAS,EAAE,MAAM,OAAO,GAAG;EAAC;EAAM;EAAQ,GAAG,IAAI;EAAM,GAAG;CAAQ,CAAC;CAEzE,WAAW,MAAM,QAAQ,QACxB,QAAQ,KAAK,IAAI;CAElB,IAAI,OAAO,UAAU,QAAQ,KAAK,OAAO,QAAQ;AAClD"}