Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/script/management-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class AccountManager {
}

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

recursiveFs.readdirr(directoryPath, (error?: any, directories?: string[], files?: string[]): void => {
Expand Down Expand Up @@ -405,9 +405,9 @@ class AccountManager {
});
});
} else {
getPackageFilePromise = new Promise<PackageFile>((resolve: (file: PackageFile) => void, reject: (reason: Error) => void): void => {
resolve({ isTemporary: false, path: filePath });
});
getPackageFilePromise = new Promise<PackageFile>((resolve: (file: PackageFile) => void, reject: (reason: Error) => void): void => {
resolve({ isTemporary: false, path: filePath });
});
}
return getPackageFilePromise;
}
Expand Down
96 changes: 48 additions & 48 deletions src/test/superagent-mock-config.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
// ./superagent-mock-config.js file
module.exports = [
{
pattern: 'http://localhost/(\\w+)/',
{
pattern: 'http://localhost/(\\w+)/',

/**
* returns the data
*
* @param match array Result of the resolution of the regular expression
* @param params object sent by 'send' function
*/
fixtures: function (match, params) {
return {text: "Error", status: 403, ok: false};
/**
* returns the data
*
* @param match array Result of the resolution of the regular expression
* @param params object sent by 'send' function
*/
fixtures: function (match, params) {
return { text: "Error", status: 403, ok: false };

/**
* example:
* request.get('https://error.example/404').end(function(err, res){
* console.log(err); // 404
* })
*/
if (match[1] === '404') {
throw new Error(404);
}
/**
* example:
* request.get('https://error.example/404').end(function(err, res){
* console.log(err); // 404
* })
*/
if (match[1] === '404') {
throw new Error(404);
}

/**
* example:
* request.get('https://error.example/200').end(function(err, res){
* console.log(res.body); // "Data fixtures"
* })
*/
/**
* example:
* request.get('https://error.example/200').end(function(err, res){
* console.log(res.body); // "Data fixtures"
* })
*/

/**
* example:
* request.get('https://domain.send.example/').send({superhero: "me"}).end(function(err, res){
* console.log(res.body); // "Data fixtures - superhero:me"
* })
*/
if(params["superhero"]) {
return 'Data fixtures - superhero:' + params["superhero"];
} else {
return 'Data fixtures';
}
},
/**
* example:
* request.get('https://domain.send.example/').send({superhero: "me"}).end(function(err, res){
* console.log(res.body); // "Data fixtures - superhero:me"
* })
*/
if (params["superhero"]) {
return 'Data fixtures - superhero:' + params["superhero"];
} else {
return 'Data fixtures';
}
},

/**
* returns the result of the request
*
* @param match array Result of the resolution of the regular expression
* @param data mixed Data returns by `fixtures` attribute
*/
callback: function (match, data) {
return data;
}
},
];
/**
* returns the result of the request
*
* @param match array Result of the resolution of the regular expression
* @param data mixed Data returns by `fixtures` attribute
*/
callback: function (match, data) {
return data;
}
},
];