make-folder-txt 2.1.1 → 2.1.2

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.
@@ -464,116 +464,75 @@ function checkAndInstallCompletion() {
464
464
  const homeDir = os.homedir();
465
465
  const shell = process.env.SHELL || '';
466
466
  const platform = process.platform;
467
- let completionInstalled = false;
467
+
468
+ // Use a simple flag file to track installation
469
+ const flagFile = path.join(homeDir, '.make-folder-txt-completion-installed');
470
+
471
+ if (fs.existsSync(flagFile)) {
472
+ // Completion already installed
473
+ return;
474
+ }
475
+
476
+ // Install completion
477
+ console.log('🔧 Installing shell autocompletion for make-folder-txt...');
468
478
 
469
479
  if (platform === 'win32') {
470
- // Check PowerShell completion - use the same path as the installation script
480
+ // Windows PowerShell
471
481
  try {
472
- // Get the PowerShell profile path like the installation script does
473
- const profilePathResult = execSync('powershell -Command "echo $PROFILE.CurrentUserCurrentHost"', { encoding: 'utf8' }).trim();
474
- const profilePath = profilePathResult.replace(/['"]/g, '').replace(/\.CurrentUserCurrentHost$/, ''); // Remove quotes and suffix
475
-
476
- if (fs.existsSync(profilePath)) {
477
- const profileContent = fs.readFileSync(profilePath, 'utf8');
478
- if (profileContent.includes('make-folder-txt') || profileContent.includes('Register-ArgumentCompleter')) {
479
- completionInstalled = true;
480
- }
481
- }
482
+ execSync('powershell -Command "Get-Host"', { stdio: 'ignore' });
483
+ const installScript = path.join(__dirname, '..', 'completion', 'install-powershell-completion.ps1');
484
+ execSync(`powershell -ExecutionPolicy Bypass -File "${installScript}"`, { stdio: 'ignore' });
485
+ console.log('✅ PowerShell completion installed! Restart your terminal to enable autocompletion');
482
486
  } catch (err) {
483
- // If PowerShell detection fails, try fallback paths
484
- const profilePaths = [
485
- path.join(homeDir, 'Documents', 'WindowsPowerShell', 'Microsoft.PowerShell_profile.ps1'),
486
- path.join(homeDir, 'Documents', 'PowerShell', 'Microsoft.PowerShell_profile.ps1'),
487
- path.join(homeDir, '.config', 'powershell', 'Microsoft.PowerShell_profile.ps1')
488
- ];
489
-
490
- for (const profilePath of profilePaths) {
491
- if (fs.existsSync(profilePath)) {
492
- const profileContent = fs.readFileSync(profilePath, 'utf8');
493
- if (profileContent.includes('make-folder-txt') || profileContent.includes('Register-ArgumentCompleter')) {
494
- completionInstalled = true;
495
- break;
496
- }
497
- }
498
- }
499
- }
500
- } else if (shell.includes('zsh')) {
501
- // Check zsh completion
502
- const zshrc = path.join(homeDir, '.zshrc');
503
- if (fs.existsSync(zshrc)) {
504
- const zshrcContent = fs.readFileSync(zshrc, 'utf8');
505
- if (zshrcContent.includes('make-folder-txt')) {
506
- completionInstalled = true;
507
- }
508
- }
509
- } else {
510
- // Check bash completion
511
- const bashrc = path.join(homeDir, '.bashrc');
512
- if (fs.existsSync(bashrc)) {
513
- const bashrcContent = fs.readFileSync(bashrc, 'utf8');
514
- if (bashrcContent.includes('make-folder-txt-completion')) {
515
- completionInstalled = true;
516
- }
487
+ // Silent fail for PowerShell
517
488
  }
518
- }
519
-
520
- // If completion is not installed, install it automatically (show message only first time)
521
- if (!completionInstalled) {
522
- console.log('🔧 Installing shell autocompletion for make-folder-txt...');
523
489
 
524
- if (platform === 'win32') {
525
- // Windows PowerShell
526
- try {
527
- execSync('powershell -Command "Get-Host"', { stdio: 'ignore' });
528
- const installScript = path.join(__dirname, '..', 'completion', 'install-powershell-completion.ps1');
529
- execSync(`powershell -ExecutionPolicy Bypass -File "${installScript}"`, { stdio: 'ignore' });
530
- console.log(' PowerShell completion installed! Restart your terminal to enable autocompletion');
531
- } catch (err) {
532
- // Silent fail for PowerShell
533
- }
534
- } else if (shell.includes('zsh')) {
535
- // zsh
490
+ } else if (shell.includes('zsh')) {
491
+ // zsh
492
+ try {
493
+ const zshrc = path.join(homeDir, '.zshrc');
494
+ const completionDir = path.join(homeDir, '.zsh', 'completions');
495
+ execSync(`mkdir -p "${completionDir}"`, { stdio: 'ignore' });
496
+ const completionPath = path.join(__dirname, '..', 'completion', 'make-folder-txt-completion.zsh');
497
+ execSync(`cp "${completionPath}" "${completionDir}/_make-folder-txt"`, { stdio: 'ignore' });
498
+
536
499
  try {
537
- const zshrc = path.join(homeDir, '.zshrc');
538
- const completionDir = path.join(homeDir, '.zsh', 'completions');
539
- execSync(`mkdir -p "${completionDir}"`, { stdio: 'ignore' });
540
- const completionPath = path.join(__dirname, '..', 'completion', 'make-folder-txt-completion.zsh');
541
- execSync(`cp "${completionPath}" "${completionDir}/_make-folder-txt"`, { stdio: 'ignore' });
542
-
543
- try {
544
- const zshrcContent = fs.readFileSync(zshrc, 'utf8');
545
- if (!zshrcContent.includes('fpath+=~/.zsh/completions')) {
546
- fs.appendFileSync(zshrc, '\n# make-folder-txt completion\nfpath+=~/.zsh/completions\nautoload -U compinit && compinit\n');
547
- }
548
- } catch (e) {
549
- fs.writeFileSync(zshrc, '# make-folder-txt completion\nfpath+=~/.zsh/completions\nautoload -U compinit && compinit\n');
500
+ const zshrcContent = fs.readFileSync(zshrc, 'utf8');
501
+ if (!zshrcContent.includes('fpath+=~/.zsh/completions')) {
502
+ fs.appendFileSync(zshrc, '\n# make-folder-txt completion\nfpath+=~/.zsh/completions\nautoload -U compinit && compinit\n');
550
503
  }
551
- console.log('✅ Zsh completion installed! Restart your terminal or run: source ~/.zshrc');
552
- } catch (err) {
553
- // Silent fail for zsh
504
+ } catch (e) {
505
+ fs.writeFileSync(zshrc, '# make-folder-txt completion\nfpath+=~/.zsh/completions\nautoload -U compinit && compinit\n');
554
506
  }
555
- } else {
556
- // bash
507
+ console.log('✅ Zsh completion installed! Restart your terminal or run: source ~/.zshrc');
508
+ } catch (err) {
509
+ // Silent fail for zsh
510
+ }
511
+
512
+ } else {
513
+ // bash
514
+ try {
515
+ const bashrc = path.join(homeDir, '.bashrc');
516
+ const completionPath = path.join(__dirname, '..', 'completion', 'make-folder-txt-completion.bash');
557
517
  try {
558
- const bashrc = path.join(homeDir, '.bashrc');
559
- const completionPath = path.join(__dirname, '..', 'completion', 'make-folder-txt-completion.bash');
560
- try {
561
- const bashrcContent = fs.readFileSync(bashrc, 'utf8');
562
- if (!bashrcContent.includes('make-folder-txt-completion.bash')) {
563
- fs.appendFileSync(bashrc, `\n# make-folder-txt completion\nsource "${completionPath}"\n`);
564
- }
565
- } catch (e) {
566
- fs.writeFileSync(bashrc, `# make-folder-txt completion\nsource "${completionPath}"\n`);
518
+ const bashrcContent = fs.readFileSync(bashrc, 'utf8');
519
+ if (!bashrcContent.includes('make-folder-txt-completion.bash')) {
520
+ fs.appendFileSync(bashrc, `\n# make-folder-txt completion\nsource "${completionPath}"\n`);
567
521
  }
568
- console.log('✅ Bash completion installed! Restart your terminal or run: source ~/.bashrc');
569
- } catch (err) {
570
- // Silent fail for bash
522
+ } catch (e) {
523
+ fs.writeFileSync(bashrc, `# make-folder-txt completion\nsource "${completionPath}"\n`);
571
524
  }
525
+ console.log('✅ Bash completion installed! Restart your terminal or run: source ~/.bashrc');
526
+ } catch (err) {
527
+ // Silent fail for bash
572
528
  }
573
-
574
- console.log('💡 Restart your terminal to enable autocompletion');
575
- console.log('');
576
529
  }
530
+
531
+ // Create flag file to prevent re-installation
532
+ fs.writeFileSync(flagFile, 'installed');
533
+ console.log('💡 Restart your terminal to enable autocompletion');
534
+ console.log('');
535
+
577
536
  } catch (err) {
578
537
  // Silent fail - don't interrupt the main functionality
579
538
  }
@@ -21,7 +21,7 @@ FILE: /package.json
21
21
  --------------------------------------------------------------------------------
22
22
  {
23
23
  "name": "make-folder-txt",
24
- "version": "2.1.0",
24
+ "version": "2.1.1",
25
25
  "description": "Generate a single .txt file containing the full folder structure and file contents of any project, ignoring node_modules and other junk.",
26
26
  "main": "bin/make-folder-txt.js",
27
27
  "bin": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "make-folder-txt",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "Generate a single .txt file containing the full folder structure and file contents of any project, ignoring node_modules and other junk.",
5
5
  "main": "bin/make-folder-txt.js",
6
6
  "bin": {