本文整理汇总了TypeScript中vsts-task-lib/task.exist函数的典型用法代码示例。如果您正苦于以下问题:TypeScript exist函数的具体用法?TypeScript exist怎么用?TypeScript exist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exist函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
coreApi.restClient.get(packageUrl, ApiVersion, null, { responseIsCollection: false }, async function (error, status, result) {
if (!!error && status != 200) {
reject(tl.loc("FailedToGetPackageMetadata", error));
}
var packageType = result.protocolType.toLowerCase();
var packageName = result.name;
if (packageType == "nuget") {
var downloadUrl = await getDownloadUrl(coreApi.vsoClient, feedId, packageName, version);
if (!tl.exist(downloadPath)) {
tl.mkdirP(downloadPath);
}
var zipLocation = path.resolve(downloadPath, "/../", packageName) + ".zip";
var unzipLocation = path.join(downloadPath, "");
console.log(tl.loc("StartingDownloadOfPackage", packageName, zipLocation));
await downloadNugetPackage(coreApi, downloadUrl, zipLocation);
console.log(tl.loc("ExtractingNugetPackage", packageName, unzipLocation));
await unzip(zipLocation, unzipLocation);
if (tl.exist(zipLocation)) {
tl.rmRF(zipLocation, false);
}
resolve();
}
else {
reject(tl.loc("PackageTypeNotSupported"));
}
});
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:33,代码来源:download.ts
示例2: isVersionInstalled
public isVersionInstalled(version: string): boolean {
if (!toolLib.isExplicitVersion(version)) {
throw tl.loc("ExplicitVersionRequired", version);
}
var isInstalled: boolean = false;
if (this.packageType == utils.Constants.sdk) {
isInstalled = tl.exist(path.join(this.installationPath, utils.Constants.relativeSdkPath, version)) && tl.exist(path.join(this.installationPath, utils.Constants.relativeSdkPath, `${version}.complete`));
}
else {
isInstalled = tl.exist(path.join(this.installationPath, utils.Constants.relativeRuntimePath, version)) && tl.exist(path.join(this.installationPath, utils.Constants.relativeRuntimePath, `${version}.complete`));
}
isInstalled ? console.log(tl.loc("VersionFoundInCache", version)) : console.log(tl.loc("VersionNotFoundInCache", version));
return isInstalled;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:16,代码来源:versioninstaller.ts
示例3: isLatestInstalledVersion
private isLatestInstalledVersion(version: string): boolean {
var pathTobeChecked = this.packageType == utils.Constants.sdk ? path.join(this.installationPath, utils.Constants.relativeSdkPath) : path.join(this.installationPath, utils.Constants.relativeRuntimePath);
if (!tl.exist(pathTobeChecked)) {
throw tl.loc("PathNotFoundException", pathTobeChecked);
}
var allEnteries: string[] = tl.ls("", [pathTobeChecked]).map(name => path.join(pathTobeChecked, name));
var folderPaths: string[] = allEnteries.filter(element => fs.lstatSync(element).isDirectory());
var isLatest: boolean = folderPaths.findIndex(folderPath => {
try {
let versionFolderName = path.basename(folderPath);
tl.debug(tl.loc("ComparingInstalledFolderVersions", version, versionFolderName));
return utils.versionCompareFunction(versionFolderName, version) > 0;
}
catch (ex) {
// no op, folder name might not be in version format
}
}) < 0;
var filePaths: string[] = allEnteries.filter(element => !fs.lstatSync(element).isDirectory());
isLatest = isLatest && filePaths.findIndex(filePath => {
try {
var versionCompleteFileName = this.getVersionCompleteFileName(path.basename(filePath));
tl.debug(tl.loc("ComparingInstalledFileVersions", version, versionCompleteFileName));
return utils.versionCompareFunction(versionCompleteFileName, version) > 0
}
catch (ex) {
// no op, file name might not be in version format
}
}) < 0;
isLatest ? tl.debug(tl.loc("VersionIsLocalLatest", version, this.installationPath)) : tl.debug(tl.loc("VersionIsNotLocalLatest", version, this.installationPath));
return isLatest;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:34,代码来源:versioninstaller.ts
示例4: saveFileWithName
export function saveFileWithName(file: string, name: string, filePath: string): void {
if (file && tl.exist(file)) {
let destination = path.join(filePath, name + '.npmrc');
tl.debug(tl.loc('SavingFile', file));
copyFile(file, destination);
}
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:7,代码来源:util.ts
示例5: deleteSecureFile
/**
* Delete secure file from the temporary location for the build
* @param secureFileId
*/
deleteSecureFile(secureFileId: string): void {
const tempDownloadPath: string = this.getSecureFileTempDownloadPath(secureFileId);
if (tl.exist(tempDownloadPath)) {
tl.debug('Deleting secure file at: ' + tempDownloadPath);
tl.rmRF(tempDownloadPath);
}
}
开发者ID:grawcho,项目名称:vso-agent-tasks,代码行数:11,代码来源:securefiles-common.ts
示例6: run
export function run(connection: ContainerConnection, outputUpdate: (data: string) => any, ignoreArguments?: boolean): any {
let commandArguments = ignoreArguments ? "" : tl.getInput("arguments");
// get tags input
let tags = tl.getDelimitedInput("tags", "\n");
// get qualified image name from the containerRegistry input
let repositoryName = tl.getInput("repository");
let imageNames: string[] = [];
// if container registry is provided, use that
// else, use the currently logged in registries
if (tl.getInput("containerRegistry")) {
let imageName = connection.getQualifiedImageName(repositoryName);
if (imageName) {
imageNames.push(imageName);
}
}
else {
imageNames = connection.getQualifiedImageNamesFromConfig(repositoryName);
}
const dockerfilepath = tl.getInput("dockerFile", true);
const dockerFile = findDockerFile(dockerfilepath);
if (!tl.exist(dockerFile)) {
throw new Error(tl.loc('ContainerDockerFileNotFound', dockerfilepath));
}
// push all tags
let output = "";
let outputImageName = "";
let digest = "";
let imageSize = "";
let promise = pushMultipleImages(connection, imageNames, tags, commandArguments, (image, commandOutput) => {
output += commandOutput;
outputImageName = image;
let extractedResult = extractDigestAndSizeFromOutput(commandOutput, matchPatternForDigestAndSize);
digest = extractedResult[0];
imageSize = extractedResult[1];
tl.debug("outputImageName: " + outputImageName + "\n" + "commandOutput: " + commandOutput + "\n" + "digest:" + digest + "imageSize:" + imageSize);
publishToImageMetadataStore(connection, outputImageName, tags, digest, dockerFile, imageSize).then((result) => {
tl.debug("ImageDetailsApiResponse: " + result);
}, (error) => {
tl.warning("publishToImageMetadataStore failed with error: " + error);
});
});
if (promise) {
promise = promise.then(() => {
let taskOutputPath = utils.writeTaskOutput("push", output);
outputUpdate(taskOutputPath);
});
}
else {
tl.debug(tl.loc('NotPushingAsNoLoginFound'));
promise = Q.resolve(null);
}
return promise;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:59,代码来源:dockerpush.ts
示例7: run
export function run(connection: ContainerConnection): any {
var command = connection.createCommand();
command.arg("build");
var dockerfilepath = tl.getInput("dockerFile", true);
var dockerFile = findDockerFile(dockerfilepath);
if(!tl.exist(dockerFile)) {
throw new Error(tl.loc('ContainerDockerFileNotFound', dockerfilepath));
}
command.arg(["-f", dockerFile]);
tl.getDelimitedInput("buildArguments", "\n").forEach(buildArgument => {
command.arg(["--build-arg", buildArgument]);
});
var imageName = utils.getImageName();
var qualifyImageName = tl.getBoolInput("qualifyImageName");
if (qualifyImageName) {
imageName = connection.qualifyImageName(imageName);
}
command.arg(["-t", imageName]);
var baseImageName = imageUtils.imageNameWithoutTag(imageName);
tl.getDelimitedInput("additionalImageTags", "\n").forEach(tag => {
command.arg(["-t", baseImageName + ":" + tag]);
});
var includeSourceTags = tl.getBoolInput("includeSourceTags");
if (includeSourceTags) {
sourceUtils.getSourceTags().forEach(tag => {
command.arg(["-t", baseImageName + ":" + tag]);
});
}
var includeLatestTag = tl.getBoolInput("includeLatestTag");
if (baseImageName !== imageName && includeLatestTag) {
command.arg(["-t", baseImageName]);
}
var memory = tl.getInput("memory");
if (memory) {
command.arg(["-m", memory]);
}
var context: string;
var defaultContext = tl.getBoolInput("defaultContext");
if (defaultContext) {
context = path.dirname(dockerFile);
} else {
context = tl.getPathInput("context");
}
command.arg(context);
return connection.execCommand(command);
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:57,代码来源:containerbuild.ts
示例8: run
export function run(connection: ContainerConnection): any {
var command = connection.createCommand();
command.arg("build");
var dockerfilepath = tl.getInput("dockerFile", true);
let dockerFile = fileUtils.findDockerFile(dockerfilepath);
if(!tl.exist(dockerFile)) {
throw new Error(tl.loc('ContainerDockerFileNotFound', dockerfilepath));
}
command.arg(["-f", dockerFile]);
var addDefaultLabels = tl.getBoolInput("addDefaultLabels");
if (addDefaultLabels) {
pipelineUtils.addDefaultLabelArgs(command);
}
var commandArguments = tl.getInput("arguments", false);
command.line(commandArguments);
var imageName = utils.getImageName();
var qualifyImageName = tl.getBoolInput("qualifyImageName");
if (qualifyImageName) {
imageName = connection.getQualifiedImageNameIfRequired(imageName);
}
command.arg(["-t", tl.getBoolInput("enforceDockerNamingConvention") ? imageUtils.generateValidImageName(imageName) : imageName]);
var baseImageName = imageUtils.imageNameWithoutTag(imageName);
var includeSourceTags = tl.getBoolInput("includeSourceTags");
if (includeSourceTags) {
sourceUtils.getSourceTags().forEach(tag => {
command.arg(["-t", baseImageName + ":" + tag]);
});
}
var includeLatestTag = tl.getBoolInput("includeLatestTag");
if (baseImageName !== imageName && includeLatestTag) {
command.arg(["-t", baseImageName]);
}
var memoryLimit = tl.getInput("memoryLimit");
if (memoryLimit) {
command.arg(["-m", memoryLimit]);
}
var context: string;
var useDefaultContext = tl.getBoolInput("useDefaultContext");
if (useDefaultContext) {
context = path.dirname(dockerFile);
} else {
context = tl.getPathInput("buildContext");
}
command.arg(context);
return connection.execCommand(command);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:57,代码来源:containerbuild.ts
示例9:
this.additionalDockerComposeFiles.forEach(file => {
// If the path is relative, resolve it
if (file.indexOf("/") !== 0) {
file = path.join(basePath, file);
}
if (this.requireAdditionalDockerComposeFiles || tl.exist(file)) {
command.arg(["-f", file]);
}
});
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:9,代码来源:dockercomposeconnection.ts
示例10: findGlobalBower
function findGlobalBower(): string {
let bowerPath = tl.which("bower", false);
tl.debug(`checking path: ${bowerPath}`);
if (tl.exist(bowerPath)) {
return bowerPath;
}
const
globalPrefix = getNPMPrefix(),
isWin = process.platform.indexOf("win") === 0;
bowerPath = path.join(globalPrefix, "bower" + (isWin ? ".cmd" : ""));
tl.debug(`checking path: ${bowerPath}`);
if (tl.exist(bowerPath)) {
return bowerPath;
}
}
开发者ID:touchifyapp,项目名称:vsts-bower,代码行数:19,代码来源:bowertask.ts
注:本文中的vsts-task-lib/task.exist函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论