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 {
8
8
getListTable ,
9
9
mapToVisiblityCode ,
10
10
tokenGuard ,
11
11
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 ) {
24
15
if ( tokenGuard ( apiToken ) ) {
25
16
return 'Please provide your pastebin.com API token in the ~/.pasty.api file.' ;
26
17
}
@@ -56,7 +47,7 @@ async function loginUser(argv, apiToken) {
56
47
}
57
48
}
58
49
59
- async function listPastes ( amount , apiToken , userToken ) {
50
+ export async function listPastes ( amount , apiToken , userToken ) {
60
51
if ( tokenGuard ( apiToken ) ) {
61
52
return 'Please provide your pastebin.com API token in the ~/.pasty.api file.' ;
62
53
}
@@ -83,15 +74,15 @@ async function listPastes(amount, apiToken, userToken) {
83
74
}
84
75
}
85
76
86
- function logout ( ) {
77
+ export function logout ( ) {
87
78
if ( existsSync ( `${ homedir } /.pasty.user` ) ) {
88
79
rmSync ( `${ homedir ( ) } /.pasty.user` ) ;
89
80
return 'Successfully logged you out.' ;
90
81
}
91
82
return "You're currently not logged in (could not find ~/.pasty.user)" ;
92
83
}
93
84
94
- async function deletePaste ( pasteId , apiToken , userToken ) {
85
+ export async function deletePaste ( pasteId , apiToken , userToken ) {
95
86
if ( tokenGuard ( apiToken ) ) {
96
87
return 'Please provide your pastebin.com API token in the ~/.pasty.api file.' ;
97
88
}
@@ -113,7 +104,7 @@ async function deletePaste(pasteId, apiToken, userToken) {
113
104
return response . status === 200 ? `Success! ${ text } ` : `Error! ${ text } ` ;
114
105
}
115
106
116
- async function createPaste ( argv , apiToken , userToken ) {
107
+ export async function createPaste ( argv , apiToken , userToken ) {
117
108
if ( tokenGuard ( apiToken ) ) {
118
109
return 'Please provide your pastebin.com API token in the ~/.pasty.api file.' ;
119
110
}
@@ -152,7 +143,7 @@ async function createPaste(argv, apiToken, userToken) {
152
143
return response . status === 200 ? `Success! ${ text } ` : `Error! ${ text } ` ;
153
144
}
154
145
155
- async function getUserInfo ( apiToken , userToken ) {
146
+ export async function getUserInfo ( apiToken , userToken ) {
156
147
if ( tokenGuard ( apiToken ) ) {
157
148
return 'Please provide your pastebin.com API token in the ~/.pasty.api file.' ;
158
149
}
0 commit comments