coc-vscode-loader 1.1.9 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import * as fs from 'fs'
2
3
  import { Command } from 'commander'
3
4
  import { convert } from './convert.js'
4
5
 
@@ -14,13 +15,43 @@ program
14
15
  .description('convert a VS Code extension to coc.nvim')
15
16
  .argument('<input>', 'input directory (VS Code extension)')
16
17
  .option('-o, --output <dir>', 'output directory', './output')
17
- .option('--bridge', 'generate ts-bridge code')
18
+ .option('--convert <json>', 'convert step configuration (JSON array)')
19
+ .option('--convert-file <path>', 'path to JSON file with convert step configuration')
20
+ .option('--presets-file <path>', 'path to JSON file with preset definitions (e.g. bridge presets)')
18
21
  .option('-v, --verbose', 'verbose output')
19
22
  .action(async (input, opts) => {
23
+ let steps: any[]
24
+ let presets: any
25
+ if (opts.presetsFile) {
26
+ try { presets = JSON.parse(fs.readFileSync(opts.presetsFile, 'utf-8')) } catch {}
27
+ }
28
+ if (opts.convertFile) {
29
+ try {
30
+ const content = fs.readFileSync(opts.convertFile, 'utf-8')
31
+ steps = JSON.parse(content)
32
+ if (!Array.isArray(steps)) throw new Error('must be an array')
33
+ } catch (e: any) {
34
+ console.error(`invalid --convert-file: ${e.message}`)
35
+ process.exit(1)
36
+ }
37
+ } else if (opts.convert) {
38
+ try {
39
+ steps = JSON.parse(opts.convert)
40
+ if (!Array.isArray(steps)) throw new Error('must be an array')
41
+ } catch (e: any) {
42
+ console.error(`invalid --convert JSON: ${e.message}`)
43
+ process.exit(1)
44
+ }
45
+ } else {
46
+ console.error('--convert <JSON> or --convert-file <path> is required')
47
+ process.exit(1)
48
+ }
49
+
20
50
  await convert({
21
51
  input,
22
52
  output: opts.output,
23
- bridge: opts.bridge,
53
+ convert: steps,
54
+ presets,
24
55
  verbose: opts.verbose,
25
56
  })
26
57
  })