-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathcmd-json.mts
More file actions
54 lines (45 loc) · 1.31 KB
/
Copy pathcmd-json.mts
File metadata and controls
54 lines (45 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import path from 'node:path'
import { handleCmdJson } from './handle-cmd-json.mts'
import { SOCKET_JSON } from '../../constants/socket.mts'
import { defineFlags } from '../../meow.mts'
import { commonFlags } from '../../flags.mts'
import { meowOrExit } from '../../util/cli/with-subcommands.mjs'
import type { CliCommandContext } from '../../util/cli/with-subcommands.mjs'
const config = {
commandName: 'json',
description: `Display the \`${SOCKET_JSON}\` that would be applied for target folder`,
flags: defineFlags({
...commonFlags,
}),
help: (command: string) => `
Usage
$ ${command} [options] [CWD=.]
Display the \`${SOCKET_JSON}\` file that would apply when running relevant commands
in the target directory.
Examples
$ ${command}
`,
hidden: true,
}
export const cmdJson = {
description: config.description,
hidden: config.hidden,
run,
}
export async function run(
argv: string[] | readonly string[],
importMeta: ImportMeta,
{ parentName }: CliCommandContext,
): Promise<void> {
const cli = meowOrExit({
argv,
config,
parentName,
importMeta,
})
let { 0: cwd = '.' } = cli.input
// Note: path.resolve vs .join:
// If given path is absolute then cwd should not affect it.
cwd = path.resolve(process.cwd(), cwd)
await handleCmdJson(cwd)
}