All files / src/commands logout.js

100% Statements 12/12
100% Branches 0/0
100% Functions 2/2
100% Lines 12/12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261x     1x   1x   1x   1x 1x   1x   1x 1x 1x   1x 1x            
module.exports.usage = `Logout the current user
 
Usage: api logout`;
module.exports.weight = 4;
 
module.exports.category = 'utility';
 
const fs = require('fs');
 
const request = require('../lib/request');
const console = require('../utils/console');
 
const { credPath } = require('../utils/utils');
 
module.exports.run = () => {
  return request.post('/logout').then(() => {
    console.log('You have been logged out.');
 
    try {
      fs.unlinkSync(credPath);
    } catch (e) {
      //
    }
  });
};