1- const inquirer = require ( 'inquirer' ) ;
2- const fetch = require ( 'node-fetch' ) ;
3- const { API_URLS , FORMAT_CHOICES } = require ( './constant.js' ) ;
4- const { readFileSync, rmSync, writeFileSync, existsSync } = require ( 'fs' ) ;
5- const { homedir } = require ( 'os' ) ;
6- const { table } = require ( 'table' ) ;
7- const {
1+ import inquirer from 'inquirer' ;
2+ import fetch from 'node-fetch' ;
3+ import { API_URLS , FORMAT_CHOICES } from './constant.js' ;
4+ import { readFileSync , rmSync , writeFileSync , existsSync } from 'fs' ;
5+ import { homedir } from 'os' ;
6+ import { table } from 'table' ;
7+ import {
88 getListTable ,
99 mapToVisiblityCode ,
1010 tokenGuard ,
1111 getUserData ,
12- } = require ( './util.js' ) ;
13-
14- module . exports = {
15- loginUser,
16- listPastes,
17- logout,
18- deletePaste,
19- createPaste,
20- getUserInfo,
21- } ;
22-
23- async function loginUser ( argv , apiToken ) {
12+ } from './util.js' ;
13+
14+ export async function loginUser ( argv , apiToken ) {
2415 if ( tokenGuard ( apiToken ) ) {
2516 return 'Please provide your pastebin.com API token in the ~/.pasty.api file.' ;
2617 }
@@ -56,7 +47,7 @@ async function loginUser(argv, apiToken) {
5647 }
5748}
5849
59- async function listPastes ( amount , apiToken , userToken ) {
50+ export async function listPastes ( amount , apiToken , userToken ) {
6051 if ( tokenGuard ( apiToken ) ) {
6152 return 'Please provide your pastebin.com API token in the ~/.pasty.api file.' ;
6253 }
@@ -83,15 +74,15 @@ async function listPastes(amount, apiToken, userToken) {
8374 }
8475}
8576
86- function logout ( ) {
77+ export function logout ( ) {
8778 if ( existsSync ( `${ homedir } /.pasty.user` ) ) {
8879 rmSync ( `${ homedir ( ) } /.pasty.user` ) ;
8980 return 'Successfully logged you out.' ;
9081 }
9182 return "You're currently not logged in (could not find ~/.pasty.user)" ;
9283}
9384
94- async function deletePaste ( pasteId , apiToken , userToken ) {
85+ export async function deletePaste ( pasteId , apiToken , userToken ) {
9586 if ( tokenGuard ( apiToken ) ) {
9687 return 'Please provide your pastebin.com API token in the ~/.pasty.api file.' ;
9788 }
@@ -113,7 +104,7 @@ async function deletePaste(pasteId, apiToken, userToken) {
113104 return response . status === 200 ? `Success! ${ text } ` : `Error! ${ text } ` ;
114105}
115106
116- async function createPaste ( argv , apiToken , userToken ) {
107+ export async function createPaste ( argv , apiToken , userToken ) {
117108 if ( tokenGuard ( apiToken ) ) {
118109 return 'Please provide your pastebin.com API token in the ~/.pasty.api file.' ;
119110 }
@@ -152,7 +143,7 @@ async function createPaste(argv, apiToken, userToken) {
152143 return response . status === 200 ? `Success! ${ text } ` : `Error! ${ text } ` ;
153144}
154145
155- async function getUserInfo ( apiToken , userToken ) {
146+ export async function getUserInfo ( apiToken , userToken ) {
156147 if ( tokenGuard ( apiToken ) ) {
157148 return 'Please provide your pastebin.com API token in the ~/.pasty.api file.' ;
158149 }
0 commit comments