juice-email-cli 2.3.13 → 2.3.14

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/snippet.js +26 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juice-email-cli",
3
- "version": "2.3.13",
3
+ "version": "2.3.14",
4
4
  "description": "CLI tool to generate email-client-compatible HTML with juice (CSS inlining) + Mustache templating + minification",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/snippet.js CHANGED
@@ -773,8 +773,22 @@ async function runSnippetMode({ snippet, template, config: cliConfigPath, output
773
773
  priorityConfigPath = findLocalConfig(snippetDir) || findLocalConfig(process.cwd());
774
774
  } else {
775
775
  // 交互模式(只有 -s),列出片段目录下的全部配置
776
- const configs = findConfigs(snippetDir, path.basename(snippetDir));
777
- const configChoice = await promptConfig(configs);
776
+ let configs = findConfigs(snippetDir, path.basename(snippetDir));
777
+ // If -c also specified, collect from its directory too
778
+ let preferredPath = null;
779
+ if (cliConfigPath) {
780
+ preferredPath = path.resolve(cliConfigPath);
781
+ if (fs.existsSync(preferredPath)) {
782
+ const cfgDir = path.dirname(preferredPath);
783
+ if (path.resolve(cfgDir) !== path.resolve(snippetDir)) {
784
+ configs = [
785
+ ...findConfigs(cfgDir, path.basename(cfgDir)),
786
+ ...configs,
787
+ ];
788
+ }
789
+ }
790
+ }
791
+ const configChoice = await promptConfig(configs, preferredPath);
778
792
  priorityConfigPath = (configChoice.type === 'file') ? configChoice.path : null;
779
793
  }
780
794
 
@@ -877,23 +891,21 @@ async function runInteractiveMode({ config: cliConfigPath }) {
877
891
  return;
878
892
  }
879
893
 
880
- // 5. 选择配置文件
894
+ // 5. 选择配置文件 — 收集:变体目录 + 指定配置的目录
881
895
  let configs = findConfigs(variant.path, path.basename(variant.path));
882
896
 
883
- // If -c specified a config from outside the variant dir, add it to the list
884
897
  let preferredPath = null;
885
898
  if (cliConfigPath) {
886
899
  preferredPath = path.resolve(cliConfigPath);
887
- if (!configs.some(c => c.path === preferredPath) && fs.existsSync(preferredPath)) {
888
- configs = [
889
- {
890
- name: path.basename(preferredPath),
891
- path: preferredPath,
892
- isOptimal: false,
893
- source: '指定配置',
894
- },
895
- ...configs,
896
- ];
900
+ if (fs.existsSync(preferredPath)) {
901
+ const cfgDir = path.dirname(preferredPath);
902
+ // Collect from specified config's directory if different from variant dir
903
+ if (path.resolve(cfgDir) !== path.resolve(variant.path)) {
904
+ configs = [
905
+ ...findConfigs(cfgDir, path.basename(cfgDir)),
906
+ ...configs,
907
+ ];
908
+ }
897
909
  }
898
910
  }
899
911