@garyr/pt-cli 0.38.0 → 0.40.0

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/src/config.ts CHANGED
@@ -148,12 +148,24 @@ export function loadConfig(): PtConfig {
148
148
  } catch (err) {
149
149
  const error = err as Error;
150
150
  console.error(chalk.red(`\nError loading config: ${error.message}`));
151
- // If we have a backup, maybe suggest using it
152
151
  const backupPath = getConfigPath() + '.bak';
153
152
  if (fs.existsSync(backupPath)) {
154
153
  console.error(chalk.yellow(`A backup exists at ${backupPath}. You may want to restore it.`));
155
154
  }
156
- process.exit(1);
155
+
156
+ // Allow the event loop to flush console streams out to Godot before dying
157
+ setTimeout(() => {
158
+ process.exit(1);
159
+ }, 5);
160
+
161
+ // 👇 Add this return statement to satisfy the TypeScript compiler
162
+ // The application will terminate before this empty config can be used.
163
+ return {
164
+ version: '3.0',
165
+ templates: {},
166
+ default_post_config: [],
167
+ variables: []
168
+ };
157
169
  }
158
170
  }
159
171
 
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ import { fileURLToPath } from 'url';
7
7
 
8
8
  // Command imports
9
9
  import { learn } from './commands/learnCommand.js';
10
+ import { update } from './commands/updateCommand.js';
10
11
  import { init } from './commands/initCommand.js';
11
12
  import { configCommand } from './commands/configCommand.js';
12
13
  import { ignoreCommand } from './commands/ignoreCommand.js';
@@ -39,14 +40,17 @@ program
39
40
  await learn(pathArg || '.', null, options);
40
41
  } catch (err: any) {
41
42
  if (options.json) {
42
- console.log(JSON.stringify({
43
+ // Fix: Ensure the error JSON payload isn't truncated before exiting
44
+ process.stdout.write(JSON.stringify({
43
45
  type: 'error',
44
46
  message: err.message || String(err)
45
- }));
47
+ }) + '\n', () => {
48
+ process.exit(1);
49
+ });
46
50
  } else {
47
51
  console.error(chalk.red(`Error: ${err.message || err}`));
52
+ process.exit(1);
48
53
  }
49
- process.exit(1);
50
54
  }
51
55
  });
52
56
 
@@ -56,9 +60,10 @@ program
56
60
  .option('--ignore <patterns>', 'Folder patterns to ignore (comma-separated)')
57
61
  .option('-y, --yes', 'Automatically confirm prompts')
58
62
  .option('--desc <description>', 'Template description (skip prompt)')
63
+ .option('--no-diff', 'Disable additive mode, show full list')
59
64
  .action(async (templateName: string, sourcePath: string | undefined, options) => {
60
65
  try {
61
- await learn(sourcePath || '.', templateName, options);
66
+ await update(sourcePath || '.', templateName, options);
62
67
  } catch (err: any) {
63
68
  console.error(chalk.red(`Error: ${err.message || err}`));
64
69
  process.exit(1);