|
1 | 1 | import * as fs from "fs";
|
2 | 2 | import * as os from "os";
|
3 | 3 | import * as path from "path";
|
4 |
| -import Q = require("q"); |
5 | 4 | import slash = require("slash");
|
6 | 5 | import superagent = require("superagent");
|
7 | 6 | import * as recursiveFs from "recursive-fs";
|
8 | 7 | import * as yazl from "yazl";
|
9 | 8 | import { CodePushUnauthorizedError } from "../utils/code-push-error"
|
10 | 9 |
|
11 |
| -import Promise = Q.Promise; |
12 |
| - |
13 | 10 | import { AccessKey, AccessKeyRequest, Account, App, AppCreationRequest, CodePushError, CollaboratorMap, CollaboratorProperties, Deployment, DeploymentMetrics, Headers, Package, PackageInfo, ServerAccessKey, Session, UpdateMetrics } from "./types";
|
14 | 11 |
|
15 | 12 | var superproxy = require("superagent-proxy");
|
@@ -75,7 +72,7 @@ class AccountManager {
|
75 | 72 | }
|
76 | 73 |
|
77 | 74 | public isAuthenticated(throwIfUnauthorized?: boolean): Promise<boolean> {
|
78 |
| - return Promise<any>((resolve, reject, notify) => { |
| 75 | + return new Promise<any>((resolve, reject) => { |
79 | 76 | var request: superagent.Request = superagent.get(this._serverUrl + urlEncode`/authenticated`);
|
80 | 77 | if (this._proxy) (<any>request).proxy(this._proxy);
|
81 | 78 | this.attachCredentials(request);
|
@@ -302,7 +299,7 @@ class AccountManager {
|
302 | 299 |
|
303 | 300 | public release(appName: string, deploymentName: string, filePath: string, targetBinaryVersion: string, updateMetadata: PackageInfo, uploadProgressCallback?: (progress: number) => void): Promise<Package> {
|
304 | 301 |
|
305 |
| - return Promise<Package>((resolve, reject, notify) => { |
| 302 | + return new Promise<Package>((resolve, reject) => { |
306 | 303 |
|
307 | 304 | updateMetadata.appVersion = targetBinaryVersion;
|
308 | 305 | var request: superagent.Request = superagent.post(this._serverUrl + urlEncode`/apps/${this.appNameParam(appName)}/deployments/${deploymentName}/release`);
|
@@ -370,7 +367,7 @@ class AccountManager {
|
370 | 367 | private packageFileFromPath(filePath: string): Promise<PackageFile> {
|
371 | 368 | var getPackageFilePromise: Promise<PackageFile>;
|
372 | 369 | if (fs.lstatSync(filePath).isDirectory()) {
|
373 |
| - getPackageFilePromise = 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 => { |
374 | 371 | var directoryPath: string = filePath;
|
375 | 372 |
|
376 | 373 | recursiveFs.readdirr(directoryPath, (error?: any, directories?: string[], files?: string[]): void => {
|
@@ -408,7 +405,9 @@ class AccountManager {
|
408 | 405 | });
|
409 | 406 | });
|
410 | 407 | } else {
|
411 |
| - getPackageFilePromise = Q({ isTemporary: false, path: filePath }); |
| 408 | + getPackageFilePromise = new Promise<PackageFile>((resolve: (file: PackageFile) => void, reject: (reason: Error) => void): void => { |
| 409 | + resolve({ isTemporary: false, path: filePath }); |
| 410 | + }); |
412 | 411 | }
|
413 | 412 | return getPackageFilePromise;
|
414 | 413 | }
|
@@ -441,7 +440,7 @@ class AccountManager {
|
441 | 440 | }
|
442 | 441 |
|
443 | 442 | private makeApiRequest(method: string, endpoint: string, requestBody: string, expectResponseBody: boolean, contentType: string): Promise<JsonResponse> {
|
444 |
| - return Promise<JsonResponse>((resolve, reject, notify) => { |
| 443 | + return new Promise<JsonResponse>((resolve, reject) => { |
445 | 444 | var request: superagent.Request = (<any>superagent)[method](this._serverUrl + endpoint);
|
446 | 445 | if (this._proxy) (<any>request).proxy(this._proxy);
|
447 | 446 | this.attachCredentials(request);
|
|
0 commit comments