piston/cli/commands/ppman_commands/uninstall.js

23 lines
778 B
JavaScript
Raw Normal View History

2021-04-10 06:10:18 +02:00
const chalk = require('chalk');
exports.command = ['uninstall <language> <language-version>']
exports.aliases = ['u']
2021-04-11 03:15:14 +02:00
exports.describe = 'Uninstalls the named package'
2021-04-10 06:10:18 +02:00
const msg_format = {
'color': p => `${p.language ? chalk.green.bold('✓') : chalk.red.bold('❌')} Uninstallation ${p.language ? "succeeded" : "failed: " + p.message}`,
'monochrome': p => `Uninstallation ${p.language ? "succeeded" : "failed: " + p.message}`,
'json': JSON.stringify
}
exports.handler = async function({axios, language, languageVersion}){
try{
2021-04-11 03:15:14 +02:00
const uninstall = await axios.delete(`/packages/${language}/${languageVersion}`)
2021-04-10 06:10:18 +02:00
2021-04-11 03:15:14 +02:00
console.log(msg_format.color(uninstall.data));
2021-04-10 06:10:18 +02:00
}catch({response}){
console.error(response.data.message)
}
}