UNPKG

@zohodesk/dotkit

Version:

In this Package, we Provide Some Common Components and Hooks to Construct UI

71 lines (61 loc) 2.27 kB
const readline = require('readline'); const { exec } = require('child_process'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); console.log('\nNode.js version:', process.version); function runConsole(command, callback) { exec(command, (error, stdout, stderr) => { if (error) { console.error('Error:', error.message); return; } if (stderr) { console.error('Error:', stderr); return; } const npmVersion = stdout.trim(); console.log('\n' + command, npmVersion); callback && callback(); }); } function askQuestion1() { rl.question('\nHave you updated the changelog in README.md? (yes/no): ', (answer) => { if (answer.toLowerCase() === 'yes') { console.log('\nGreat! Proceeding...'); askQuestion2(); // rl.close(); // Call the function or code to proceed further here. } else if (answer.toLowerCase() === 'no') { rl.close(); console.log('\nPlease Update the ChangeLog in README.md, then try again'); //throw new Error('\nPlease Update the ChangeLog in README.md, then try again'); process.exitCode = 1; // Exit the Node.js process with a success code. } else { console.log('\nInvalid answer. Please enter "yes" or "no".'); askQuestion1(); // Ask the question again if the input is not "yes" or "no". } }); } function askQuestion2() { rl.question('\nHave you verified the test snapshot? (yes/no): ', (answer) => { if (answer.toLowerCase() === 'yes') { console.log('\nGreat! Proceeding...'); rl.close(); // Call the function or code to proceed further here. } else if (answer.toLowerCase() === 'no') { rl.close(); //throw new Error('\nPlease Verify the snapshot results, then try again'); console.log('\nPlease Verify the snapshot results, then try again'); process.exitCode = 1; // Exit the Node.js process with a success code. } else { console.log('\nInvalid answer. Please enter "yes" or "no".'); askQuestion2(); // Ask the question again if the input is not "yes" or "no". } }); } function getReactCliVersion() { runConsole('react-cli --version', askQuestion1); } runConsole('npm --version', getReactCliVersion);