本文整理匯總了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;
}
示例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);
});
});
示例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;
});
示例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(() => {
示例5:
.then(isRunning => {
if (isRunning) {
Log.logMessage("Attaching to running packager at port: " + port);
return Q.resolve<void>(void 0);
}
return this.remoteExtension.startPackager();
});
示例6:
.then(({ data }) => {
if (get(data, 'user.username') == null) {
return Q.reject()
} else {
return Q.resolve(data)
}
})
示例7:
.fail(function (err) {
console.error(err);
tl.debug('taskRunner fail');
gradleResult = -1;
statusFailed = true;
return Q.resolve(err);
})
示例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}`));
}
});
示例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);
}
示例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);
}