@lsst/pik-plugin-select 0.6.5 → 0.6.7

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.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Command } from "commander";
2
2
  import pc from "picocolors";
3
- import { extname, relative } from "path";
3
+ import { relative } from "path";
4
4
  import { Parser, loadConfig, SingleSwitcher } from "@lsst/pik-core";
5
5
  import { readFile, writeFile } from "fs/promises";
6
6
  import { glob } from "glob";
@@ -18,8 +18,7 @@ class Scanner {
18
18
  const results = [];
19
19
  for (const filePath of files) {
20
20
  const content = await readFile(filePath, "utf-8");
21
- const extension = extname(filePath);
22
- const parser = Parser.forExtension(extension);
21
+ const parser = Parser.forFilePath(filePath);
23
22
  const { selectors } = parser.parse(content);
24
23
  if (selectors.length > 0) {
25
24
  results.push({ path: filePath, selectors, content });
@@ -88,8 +87,7 @@ const setCommand = new Command("set").description("Set a specific option for a s
88
87
  const selector = file.selectors.find((s) => s.name === selectorName);
89
88
  if (selector) {
90
89
  found = true;
91
- const extension = extname(file.path);
92
- const switcher = SingleSwitcher.forExtension(extension);
90
+ const switcher = SingleSwitcher.forFilePath(file.path);
93
91
  try {
94
92
  const newContent = switcher.switch(file.content, selector, optionName);
95
93
  await writeFile(file.path, newContent);
@@ -182,8 +180,7 @@ const switchCommand = new Command("switch").alias("sw").description("Interactive
182
180
  if (selectedOption === BACK_VALUE) {
183
181
  continue;
184
182
  }
185
- const extension = extname(selectedChoice.file.path);
186
- const switcher = SingleSwitcher.forExtension(extension);
183
+ const switcher = SingleSwitcher.forFilePath(selectedChoice.file.path);
187
184
  const newContent = switcher.switch(
188
185
  selectedChoice.file.content,
189
186
  selectedChoice.selector,
@@ -1 +1 @@
1
- {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../src/lib/commands/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,OAAO,aAAa,CAAC;AAErB,eAAO,MAAM,UAAU,SA8CnB,CAAC"}
1
+ {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../src/lib/commands/set.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,OAAO,aAAa,CAAC;AAErB,eAAO,MAAM,UAAU,SA6CnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/lib/commands/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,OAAO,aAAa,CAAC;AAarB,eAAO,MAAM,aAAa,SA0GtB,CAAC"}
1
+ {"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../src/lib/commands/switch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,OAAO,aAAa,CAAC;AAarB,eAAO,MAAM,aAAa,SAyGtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/lib/scanner.ts"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAE3C,IAAI,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAsB/D"}
1
+ {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/lib/scanner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,OAAO;IACN,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAE3C,IAAI,CAAC,GAAG,GAAE,MAAsB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;CAqB/D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lsst/pik-plugin-select",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "Config selector plugin for pik CLI",
5
5
  "type": "module",
6
6
  "license": "MIT",