moshai-cli
Version:
A modern, fast Node.js CLI powered by arasadrahman
38 lines (33 loc) • 1.07 kB
JavaScript
const git = require('simple-git')();
const chalk = require('chalk').default;
module.exports = class PushCommand {
static signature = 'git:push {message?}';
static description = 'Add, commit and push changes';
async handle({ message }) {
if (!message) {
message = 'Update: ' + new Date().toLocaleString();
}
try {
await this.withSpinner(
git.add('.'),
'Adding changes...',
'Changes added!',
'❌ Failed to add changes.'
);
await this.withSpinner(
git.commit(message),
'Committing changes...',
'Commit successful!',
'❌ Commit failed.'
);
await this.withSpinner(
git.push(),
'Pushing to remote...',
'Push successful!',
'❌ Push failed.'
);
} catch (err) {
this.error(err.message);
}
}
};