8000 Use require instead of import · rclone/rclone-js-api@ff1c73b · GitHub
[go: up one dir, main page]

Skip to content

Commit ff1c73b

Browse files
committed
Use require instead of import
1 parent 86bb71c commit ff1c73b

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,6 @@ temp/
196196

197197
# End of https://www.gitignore.io/api/node,intellij+all
198198

199-
/lib/
199+
/lib/
200+
201+
/.idea/

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"main": "lib/index.js",
66
"scripts": {
77
"test": "echo \"Skipping tests for now TODO\"",
8-
"compile:commonjs": "better-npm-run compile:commonjs",
9-
"compile:es": "babel -d es/ src/",
10-
"compile": "babel src --out-dir lib",
8+
"compile:es": "babel src --out-dir lib",
9+
"compile": "npm run compile:es ",
1110
"prepare": "npm run compile"
1211
},
1312
"babel": {

src/axiosInstance.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import axios from "axios";
2-
import {AUTH_KEY, IP_ADDRESS_KEY} from "./constants";
1+
const axios = require("axios");
2+
3+
const constants = require("./constants");
34

45
/**
56
* Global level axios configuration. These settings are automatically used in other places by using an axiosInstance instead of axios directly
@@ -14,11 +15,12 @@ export let axiosInstance = axios.create({
1415
*/
1516
axiosInstance.interceptors.request.use(
1617
config => {
17-
config.baseURL = localStorage.getItem(IP_ADDRESS_KEY);
18+
config.baseURL = localStorage.getItem(constants.IP_ADDRESS_KEY);
1819

19-
config.headers.Authorization = 'Basic ' + localStorage.getItem(AUTH_KEY);
20+
config.headers.Authorization = 'Basic ' + localStorage.getItem(constants.AUTH_KEY);
2021
return config;
2122
},
2223
error => Promise.reject(error)
2324
);
2425

26+
export default axiosInstance;

src/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {axiosInstance} from "./axiosInstance";
2-
import urls from "./endpoint";
3-
import {addColonAtLast, isLocalRemoteName} from "./Tools";
1+
const axiosInstance = require('./axiosInstance');
2+
const urls = require('./endpoint');
3+
const tools = require('./Tools')
44

55
/**
66
* getStats returns the current rclone stats.
@@ -52,7 +52,7 @@ export const setCurrentBandwidthSetting = (newRate) => {
5252
* @returns {Function}
5353
*/
5454
export const createNewPublicLink = (remoteName, remotePath) => {
55-
remoteName = addColonAtLast(remoteName);
55+
remoteName = tools.addColonAtLast(remoteName);
5656
return new Promise((resolve, reject) => {
5757
axiosInstance.post(urls.createPublicLink, {fs: remoteName, remote: remotePath}).then(res => {
5858
resolve(res.data);
@@ -209,8 +209,9 @@ export const getJobStatus = (jobId) => {
209209
}
210210

211211
/**
212-
* purgeDir returns the status of a job with jobId
213-
* @param jobId {number} Valid job id
212+
* purgeDir deletes the directory with given fs and remote
213+
* @param fs {string} Name of fs
214+
* @param remote {string} path remoteName
214215
* @return {Promise<unknown>}
215216
*/
216217
export const purgeDir = (fs , remote) => {
@@ -248,7 +249,7 @@ export const deleteFile = (fs , remote) => {
248249
}
249250

250251
/**
251-
* cleanTrashForRemote returns the status of a job with jobId
252+
* cleanTrashForRemote cleans the trash for the remote with remote fs
252253
* @param fs {string} Remote Name
253254
* @return {Promise<unknown>}
254255
*/

0 commit comments

Comments
 (0)
0