Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 5594942

Browse files
authored
Code refactoring (#725)
1 parent 9fde20b commit 5594942

File tree

2 files changed

+53
-53
lines changed

2 files changed

+53
-53
lines changed

src/script/management-sdk.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class AccountManager {
7272
}
7373

7474
public isAuthenticated(throwIfUnauthorized?: boolean): Promise<boolean> {
75-
return new Promise<any>((resolve, reject) => {
75+
return new Promise<any>((resolve, reject) => {
7676
var request: superagent.Request = superagent.get(this._serverUrl + urlEncode`/authenticated`);
7777
if (this._proxy) (<any>request).proxy(this._proxy);
7878
this.attachCredentials(request);
@@ -367,7 +367,7 @@ class AccountManager {
367367
private packageFileFromPath(filePath: string): Promise<PackageFile> {
368368
var getPackageFilePromise: Promise<PackageFile>;
369369
if (fs.lstatSync(filePath).isDirectory()) {
370-
getPackageFilePromise = new Promise<PackageFile>((resolve: (file: PackageFile) => void, reject: (reason: Error) => void): void => {
370+
getPackageFilePromise = new Promise<PackageFile>((resolve: (file: PackageFile) => void, reject: (reason: Error) => void): void => {
371371
var directoryPath: string = filePath;
372372

373373
recursiveFs.readdirr(directoryPath, (error?: any, directories?: string[], files?: string[]): void => {
@@ -405,9 +405,9 @@ class AccountManager {
405405
});
406406
});
407407
} else {
408-
getPackageFilePromise = new Promise<PackageFile>((resolve: (file: PackageFile) => void, reject: (reason: Error) => void): void => {
409-
resolve({ isTemporary: false, path: filePath });
410-
});
408+
getPackageFilePromise = new Promise<PackageFile>((resolve: (file: PackageFile) => void, reject: (reason: Error) => void): void => {
409+
resolve({ isTemporary: false, path: filePath });
410+
});
411411
}
412412
return getPackageFilePromise;
413413
}

src/test/superagent-mock-config.js

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
// ./superagent-mock-config.js file
22
module.exports = [
3-
{
4-
pattern: 'http://localhost/(\\w+)/',
3+
{
4+
pattern: 'http://localhost/(\\w+)/',
55

6-
/**
7-
* returns the data
8-
*
9-
* @param match array Result of the resolution of the regular expression
10-
* @param params object sent by 'send' function
11-
*/
12-
fixtures: function (match, params) {
13-
return {text: "Error", status: 403, ok: false};
6+
/**
7+
* returns the data
8+
*
9+
* @param match array Result of the resolution of the regular expression
10+
* @param params object sent by 'send' function
11+
*/
12+
fixtures: function (match, params) {
13+
return { text: "Error", status: 403, ok: false };
1414

15-
/**
16-
* example:
17-
* request.get('https://error.example/404').end(function(err, res){
18-
* console.log(err); // 404
19-
* })
20-
*/
21-
if (match[1] === '404') {
22-
throw new Error(404);
23-
}
15+
/**
16+
* example:
17+
* request.get('https://error.example/404').end(function(err, res){
18+
* console.log(err); // 404
19+
* })
20+
*/
21+
if (match[1] === '404') {
22+
throw new Error(404);
23+
}
2424

25-
/**
26-
* example:
27-
* request.get('https://error.example/200').end(function(err, res){
28-
* console.log(res.body); // "Data fixtures"
29-
* })
30-
*/
25+
/**
26+
* example:
27+
* request.get('https://error.example/200').end(function(err, res){
28+
* console.log(res.body); // "Data fixtures"
29+
* })
30+
*/
3131

32-
/**
33-
* example:
34-
* request.get('https://domain.send.example/').send({superhero: "me"}).end(function(err, res){
35-
* console.log(res.body); // "Data fixtures - superhero:me"
36-
* })
37-
*/
38-
if(params["superhero"]) {
39-
return 'Data fixtures - superhero:' + params["superhero"];
40-
} else {
41-
return 'Data fixtures';
42-
}
43-
},
32+
/**
33+
* example:
34+
* request.get('https://domain.send.example/').send({superhero: "me"}).end(function(err, res){
35+
* console.log(res.body); // "Data fixtures - superhero:me"
36+
* })
37+
*/
38+
if (params["superhero"]) {
39+
return 'Data fixtures - superhero:' + params["superhero"];
40+
} else {
41+
return 'Data fixtures';
42+
}
43+
},
4444

45-
/**
46-
* returns the result of the request
47-
*
48-
* @param match array Result of the resolution of the regular expression
49-
* @param data mixed Data returns by `fixtures` attribute
50-
*/
51-
callback: function (match, data) {
52-
return data;
53-
}
54-
},
55-
];
45+
/**
46+
* returns the result of the request
47+
*
48+
* @param match array Result of the resolution of the regular expression
49+
* @param data mixed Data returns by `fixtures` attribute
50+
*/
51+
callback: function (match, data) {
52+
return data;
53+
}
54+
},
55+
];

0 commit comments

Comments
 (0)