cueme 0.1.10 → 0.1.11

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/cli.js +25 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cueme",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Cue command protocol adapter (stdin/stdout JSON)",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
package/src/cli.js CHANGED
@@ -159,6 +159,7 @@ async function main() {
159
159
  const { execSync } = require('child_process');
160
160
  const os = require('os');
161
161
  const path = require('path');
162
+ const fs = require('fs');
162
163
 
163
164
  try {
164
165
  // Get PowerShell profile path
@@ -176,36 +177,31 @@ async function main() {
176
177
  '$OutputEncoding = $utf8NoBom',
177
178
  ].join('\n');
178
179
 
179
- // Create PowerShell script to fix encoding
180
- const psScript = [
181
- `$profilePath = '${profilePath.replace(/\\/g, '\\')}'`,
182
- `$encodingConfig = @'`,
183
- encodingConfig,
184
- `'@`,
185
- '',
186
- '$profileDir = Split-Path -Parent $profilePath',
187
- 'if (!(Test-Path $profileDir)) {',
188
- ' New-Item -Path $profileDir -ItemType Directory -Force | Out-Null',
189
- '}',
190
- '',
191
- 'if (!(Test-Path $profilePath)) {',
192
- ' New-Item -Path $profilePath -ItemType File -Force | Out-Null',
193
- ' Write-Host "Created PowerShell profile"',
194
- '}',
195
- '',
196
- '$content = Get-Content $profilePath -Raw -ErrorAction SilentlyContinue',
197
- 'if ($content -notlike "*utf8NoBom*") {',
198
- ' Add-Content -Path $profilePath -Value "`n$encodingConfig"',
199
- ' Write-Host "Added UTF-8 encoding to PowerShell profile"',
200
- ' Write-Host "Please restart PowerShell for changes to take effect"',
201
- '} else {',
202
- ' Write-Host "UTF-8 encoding already configured"',
203
- '}',
204
- ].join('; ');
180
+ // Ensure profile directory exists
181
+ const profileDir = path.dirname(profilePath);
182
+ if (!fs.existsSync(profileDir)) {
183
+ fs.mkdirSync(profileDir, { recursive: true });
184
+ process.stdout.write('Created PowerShell profile directory\n');
185
+ }
186
+
187
+ // Check if profile exists and if encoding is already configured
188
+ let needsUpdate = true;
189
+ if (fs.existsSync(profilePath)) {
190
+ const content = fs.readFileSync(profilePath, 'utf8');
191
+ if (content.includes('utf8NoBom')) {
192
+ process.stdout.write('UTF-8 encoding already configured\n');
193
+ needsUpdate = false;
194
+ }
195
+ } else {
196
+ process.stdout.write('Created PowerShell profile\n');
197
+ }
205
198
 
206
- execSync(`powershell -NoProfile -Command "${psScript}"`, {
207
- stdio: 'inherit',
208
- });
199
+ // Add encoding configuration if needed
200
+ if (needsUpdate) {
201
+ fs.appendFileSync(profilePath, '\n' + encodingConfig + '\n');
202
+ process.stdout.write('Added UTF-8 encoding to PowerShell profile\n');
203
+ process.stdout.write('Please restart PowerShell for changes to take effect\n');
204
+ }
209
205
 
210
206
  } catch (err) {
211
207
  process.stderr.write(`Failed to fix PowerShell encoding: ${err.message}\n`);