pixelblock-cli
Advanced tools
Comparing version 0.0.34 to 0.0.35
@@ -7,2 +7,3 @@ #!/usr/bin/env node | ||
const { execSync } = require('child_process'); | ||
const readline = require('readline'); // Import readline for user input | ||
const packageJson = require('../package.json'); // Ensure this path is correct | ||
@@ -12,4 +13,19 @@ | ||
// Function to ask the user a yes/no question | ||
const askQuestion = (question) => { | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
}); | ||
return new Promise((resolve) => { | ||
rl.question(`${question} (yes/no): `, (answer) => { | ||
rl.close(); | ||
resolve(answer.toLowerCase() === 'yes'); | ||
}); | ||
}); | ||
}; | ||
program | ||
.version(packageJson.version) // Set the version from package.json | ||
.version(packageJson.version) | ||
.command('add <component>') | ||
@@ -27,2 +43,12 @@ .description('Add a PixelBlockUI component') | ||
fs.ensureDirSync(destinationDir); | ||
if (fs.existsSync(destinationFile)) { | ||
// Ask the user if they want to replace the existing file | ||
const shouldReplace = await askQuestion(`File ${component}.tsx already exists. Do you want to replace it?`); | ||
if (!shouldReplace) { | ||
console.log('Operation canceled. No files were changed.'); | ||
return; | ||
} | ||
} | ||
fs.copyFileSync(sourceFile, destinationFile); | ||
@@ -29,0 +55,0 @@ console.log(`Component ${component} installed successfully.`); |
{ | ||
"name": "pixelblock-cli", | ||
"version": "0.0.34", | ||
"version": "0.0.35", | ||
"main": "bin/install.js", | ||
@@ -5,0 +5,0 @@ "bin": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28874
762