本文整理汇总了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);
}