當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Q.resolve函數代碼示例

本文整理匯總了TypeScript中Q.resolve函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript resolve函數的具體用法?TypeScript resolve怎麽用?TypeScript resolve使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了resolve函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: uploadFiles

	function uploadFiles(files) {
		var funcs = [];
		
		files.forEach((file) => {	
			// replace backslash with forward slash
			var srcPath = file.relative.replace(/\\/g,"/");
			// strip out bad characters
			var remotePath = srcPath.replace(/^\/|\/$/g, '') + ';'; // ';' needed to fix the url

			funcs.push(() => { 
				try {
					return bintray.uploadPackage(options.pkg.name, options.pkg.version, srcPath, remotePath)
						.then((res) => {
								_stream.push(file);
								gutil.log(gutil.colors.yellow('Deployed ' + srcPath + ' to remote path ' + remotePath));
							}, (err) => {
								gutil.log(gutil.colors.red('Failed to deploy ' + srcPath + ' to remote path ' + remotePath + formatErr(err)));
								throw err;
							})
				} catch(err) {
					gutil.log(gutil.colors.red('Failed to deploy ' + srcPath + ' to remote path ' + remotePath + formatErr(err)));
					return Q.reject(err);
				}
			});
		});

		var result = Q.resolve(true);
		funcs.forEach((f) => {
			result = result.then(() => { return f() }, (err) => { throw err; } );
		});

		return result;
	}
開發者ID:frankwallis,項目名稱:gulp-bintray,代碼行數:33,代碼來源:index.ts

示例2: test

        test("setPlistProperty should attempt to modify, then add, plist properties", function() {
            const plistFileName = "testFile.plist";
            const plistProperty = ":RCTDevMenu:ExecutorClass";
            const plistValue = "RCTWebSocketExecutor";

            const setCallArgs = `/usr/libexec/PlistBuddy -c 'Set ${plistProperty} ${plistValue}' '${plistFileName}'`;
            const addCallArgs = `/usr/libexec/PlistBuddy -c 'Add ${plistProperty} string ${plistValue}' '${plistFileName}'`;

            const mockedExecFunc = sinon.stub();
            mockedExecFunc.withArgs(setCallArgs).returns({ outcome: Q.reject(new Error("Setting does not exist")) });
            mockedExecFunc.withArgs(addCallArgs).returns({ outcome: Q.resolve("stdout") });
            mockedExecFunc.throws();

            const mockChildProcess: any = {
                exec: mockedExecFunc,
            };
            const plistBuddy = new PlistBuddy({ nodeChildProcess: mockChildProcess });

            return plistBuddy.setPlistProperty(plistFileName, plistProperty, plistValue)
                .then(() => {
                    assert(mockedExecFunc.calledWithExactly(setCallArgs), "plistBuddy did not attempt to set first");
                    assert(mockedExecFunc.calledWithExactly(addCallArgs), "plistBuddy did not attempt to add after set failed");
                    assert.equal(mockedExecFunc.callCount, 2);
                });
        });
開發者ID:Mokto,項目名稱:vscode-react-native,代碼行數:25,代碼來源:plistBuddy.test.ts

示例3: updateNotifier

			return Q.resolve().then(() => {
				var defer = Q.defer();
				if (notifier || !opts.getBoolean('enabled', true)) {
					return Q.resolve(notifier);
				}
				// switch if we want to wait for this
				var callback = (promise ? (err, update) => {
					if (err) {
						notifier = null;
						defer.reject(err);
					}
					else {
						notifier.update = update;
						defer.resolve(notifier);
					}
				} : undefined);

				var settings:any = {
					packageName: context.packageInfo.name,
					packageVersion: context.packageInfo.version,
					updateCheckInterval: opts.getDurationSecs('updateCheckInterval', 24 * 3600) * 1000,
					updateCheckTimeout: opts.getDurationSecs('updateCheckTimeout', 10) * 1000,
					registryUrl: opts.getString('registryUrl'),
					callback: callback
				};

				notifier = updateNotifier(settings);
				if (!callback) {
					defer.resolve(notifier);
				}
				return defer.promise;
			});
開發者ID:AbraaoAlves,項目名稱:tsd,代碼行數:32,代碼來源:update.ts

示例4:

 }).catch((error: HttpError) => {
   // ignore network failures on timeout, server forgets on session timeout anyways
   if (!error.statusCode) {
     return Q.resolve<void>(undefined);
   }
   return Q.reject<void>(error);
 }).finally(() => {
開發者ID:relution-io,項目名稱:relution-sdk,代碼行數:7,代碼來源:http.ts

示例5:

 .then(isRunning => {
     if (isRunning) {
         Log.logMessage("Attaching to running packager at port: " + port);
         return Q.resolve<void>(void 0);
     }
     return this.remoteExtension.startPackager();
 });
開發者ID:CarlosVV,項目名稱:vscode-react-native,代碼行數:7,代碼來源:generalMobilePlatform.ts

示例6:

 .then(({ data }) => {
   if (get(data, 'user.username') == null) {
     return Q.reject()
   } else {
     return Q.resolve(data)
   }
 })
開發者ID:rymizuki,項目名稱:site-animechannel,代碼行數:7,代碼來源:index.ts

示例7:

 .fail(function (err) {
     console.error(err);
     tl.debug('taskRunner fail');
     gradleResult = -1;
     statusFailed = true;
     return Q.resolve(err);
 })
開發者ID:mthalman-msft,項目名稱:vsts-tasks,代碼行數:7,代碼來源:gradletask.ts

示例8: RangeError

 return this.getReactNativeVersion().then(version => {
     if (semver.gte(version, "0.19.0")) {
         return Q.resolve<void>(void 0);
     } else {
         return Q.reject<void>(new RangeError(`Project version = ${version}`));
     }
 });
開發者ID:CarlosVV,項目名稱:vscode-react-native,代碼行數:7,代碼來源:reactNativeProjectHelper.ts

示例9: enableCodeCoverage

    // -----------------------------------------------------
    // Enable code coverage for Jacoco Gradle Builds
    // - enableCodeCoverage: CodeCoverageProperties  - ccProps
    // -----------------------------------------------------    
    public enableCodeCoverage(ccProps: { [name: string]: string }): Q.Promise<boolean> {
        let _this = this;

        tl.debug("Input parameters: " + JSON.stringify(ccProps));

        _this.buildFile = ccProps["buildfile"];
        let classFilter = ccProps["classfilter"];
        let isMultiModule = ccProps["ismultimodule"] && ccProps["ismultimodule"] === "true";
        let classFileDirs = ccProps["classfilesdirectories"];
        let reportDir = ccProps["reportdirectory"];
        let codeCoveragePluginData = null;

        let filter = _this.extractFilters(classFilter);
        let jacocoExclude = _this.applyFilterPattern(filter.excludeFilter);
        let jacocoInclude = _this.applyFilterPattern(filter.includeFilter);

        if (isMultiModule) {
            codeCoveragePluginData = ccc.jacocoGradleMultiModuleEnable(jacocoExclude.join(","), jacocoInclude.join(","), classFileDirs, reportDir);
        } else {
            codeCoveragePluginData = ccc.jacocoGradleSingleModuleEnable(jacocoExclude.join(","), jacocoInclude.join(","), classFileDirs, reportDir);
        }

        try {
            tl.debug("Code Coverage data will be appeneded to build file: " + this.buildFile);
            util.appendTextToFileSync(this.buildFile, codeCoveragePluginData);
            tl.debug("Appended code coverage data");
        } catch (error) {
            tl.warning(tl.loc("FailedToAppendCC", error));
            return Q.reject<boolean>(tl.loc("FailedToAppendCC", error));
        }
        return Q.resolve<boolean>(true);
    }
開發者ID:DarqueWarrior,項目名稱:vsts-tasks,代碼行數:36,代碼來源:jacoco.gradle.ccenabler.ts

示例10: addCodeCoverageNodes

    protected addCodeCoverageNodes(buildJsonContent: any): Q.Promise<any> {
        let _this = this;

        let buildNode = _this.getBuildDataNode(buildJsonContent);
        let pluginsNode = _this.getPluginDataNode(buildNode);
        let ccContent = ccc.jacocoMavenPluginEnable(_this.includeFilter, _this.excludeFilter, _this.reportDir);
        util.addPropToJson(pluginsNode, "plugin", ccContent);
        return Q.resolve(buildJsonContent);
    }
開發者ID:bleissem,項目名稱:vsts-tasks,代碼行數:9,代碼來源:jacoco.maven.ccenabler.ts


注:本文中的Q.resolve函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。