本文整理汇总了TypeScript中vsts-task-lib/task.osType函数的典型用法代码示例。如果您正苦于以下问题:TypeScript osType函数的具体用法?TypeScript osType怎么用?TypeScript osType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osType函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: downloadAndInstall
private async downloadAndInstall(downloadUrls: string[]) {
let downloaded = false;
let downloadPath = "";
for (const url of downloadUrls) {
try {
downloadPath = await toolLib.downloadTool(url);
downloaded = true;
break;
} catch (error) {
tl.warning(tl.loc("CouldNotDownload", url, JSON.stringify(error)));
}
}
if (!downloaded) {
throw tl.loc("FailedToDownloadPackage");
}
// extract
console.log(tl.loc("ExtractingPackage", downloadPath));
let extPath: string = tl.osType().match(/^Win/) ? await toolLib.extractZip(downloadPath) : await toolLib.extractTar(downloadPath);
// cache tool
console.log(tl.loc("CachingTool"));
let cachedDir = await toolLib.cacheDir(extPath, this.cachedToolName, this.version);
console.log(tl.loc("SuccessfullyInstalled", this.packageType, this.version));
return cachedDir;
}
开发者ID:grawcho,项目名称:vso-agent-tasks,代码行数:27,代码来源:dotnetcoreinstaller.ts
示例2: getDefaultProps
function getDefaultProps() {
return {
releaseuri: tl.getVariable('Release.ReleaseUri'),
releaseid: tl.getVariable('Release.ReleaseId'),
builduri: tl.getVariable('Build.BuildUri'),
buildid: tl.getVariable('Build.Buildid'),
osType: tl.osType()
};
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:9,代码来源:cieventlogger.ts
示例3: shouldUseVstsNuGetPush
function shouldUseVstsNuGetPush(isInternalFeed: boolean, conflictsAllowed: boolean, nugetExePath: string): boolean {
if (tl.osType() !== "Windows_NT"){
tl.debug("Running on a non-windows platform so NuGet.exe will be used.");
if(conflictsAllowed){
tl.warning(tl.loc("Warning_SkipConflictsNotSupportedUnixAgents"));
}
return false;
}
if (!isInternalFeed)
{
tl.debug("Pushing to an external feed so NuGet.exe will be used.");
return false;
}
if (commandHelper.isOnPremisesTfs())
{
tl.debug("Pushing to an onPrem environment, only NuGet.exe is supported.");
if(conflictsAllowed){
tl.warning(tl.loc("Warning_AllowDuplicatesOnlyAvailableHosted"));
}
return false;
}
const nugetOverrideFlag = tl.getVariable("NuGet.ForceNuGetForPush");
if (nugetOverrideFlag === "true") {
tl.debug("NuGet.exe is force enabled for publish.");
if(conflictsAllowed)
{
tl.warning(tl.loc("Warning_ForceNuGetCannotSkipConflicts"));
}
return false;
}
if (nugetOverrideFlag === "false") {
tl.debug("NuGet.exe is force disabled for publish.");
return true;
}
const vstsNuGetPushOverrideFlag = tl.getVariable("NuGet.ForceVstsNuGetPushForPush");
if (vstsNuGetPushOverrideFlag === "true") {
tl.debug("VstsNuGetPush.exe is force enabled for publish.");
return true;
}
if (vstsNuGetPushOverrideFlag === "false") {
tl.debug("VstsNuGetPush.exe is force disabled for publish.");
if(conflictsAllowed)
{
tl.warning(tl.loc("Warning_ForceNuGetCannotSkipConflicts"));
}
return false;
}
return true;
}
开发者ID:shubham90,项目名称:vsts-tasks,代码行数:56,代码来源:nugetpublisher.ts
示例4: getOctoCommandRunner
export function getOctoCommandRunner(command: string) : Option<ToolRunner> {
const isWindows = /windows/i.test(tasks.osType());
if(isWindows){
return stringOption(tasks.which(`${ToolName}`, false))
.map(tasks.tool)
.map(x => x.arg(command));
}
return getPortableOctoCommandRunner(command);
}
开发者ID:OctopusDeploy,项目名称:OctoTFS,代码行数:10,代码来源:tool.ts
示例5: downloadAndInstall
public async downloadAndInstall(versionInfo: VersionInfo, downloadUrl: string): Promise<void> {
if (!versionInfo || !versionInfo.getVersion() || !downloadUrl || !url.parse(downloadUrl)) {
throw tl.loc("VersionCanNotBeDownloadedFromUrl", versionInfo, downloadUrl);
}
let version = versionInfo.getVersion();
try {
try {
var downloadPath = await toolLib.downloadTool(downloadUrl)
}
catch (ex) {
throw tl.loc("CouldNotDownload", downloadUrl, ex);
}
// Extract
console.log(tl.loc("ExtractingPackage", downloadPath));
try {
var extPath = tl.osType().match(/^Win/) ? await toolLib.extractZip(downloadPath) : await toolLib.extractTar(downloadPath);
}
catch (ex) {
throw tl.loc("FailedWhileExtractingPacakge", ex);
}
// Copy folders
tl.debug(tl.loc("CopyingFoldersIntoPath", this.installationPath));
var allRootLevelEnteriesInDir: string[] = tl.ls("", [extPath]).map(name => path.join(extPath, name));
var directoriesTobeCopied: string[] = allRootLevelEnteriesInDir.filter(path => fs.lstatSync(path).isDirectory());
directoriesTobeCopied.forEach((directoryPath) => {
tl.cp(directoryPath, this.installationPath, "-rf", false);
});
// Copy files
try {
if (this.packageType == utils.Constants.sdk && this.isLatestInstalledVersion(version)) {
tl.debug(tl.loc("CopyingFilesIntoPath", this.installationPath));
var filesToBeCopied = allRootLevelEnteriesInDir.filter(path => !fs.lstatSync(path).isDirectory());
filesToBeCopied.forEach((filePath) => {
tl.cp(filePath, this.installationPath, "-f", false);
});
}
}
catch (ex) {
tl.warning(tl.loc("FailedToCopyTopLevelFiles", this.installationPath, ex));
}
// Cache tool
this.createInstallationCompleteFile(versionInfo);
console.log(tl.loc("SuccessfullyInstalled", this.packageType, version));
}
catch (ex) {
throw tl.loc("FailedWhileInstallingVersionAtPath", version, this.installationPath, ex);
}
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:55,代码来源:versioninstaller.ts
示例6: detectMachineOS
private detectMachineOS(): string[] {
let osSuffix = [];
let scriptRunner: trm.ToolRunner;
try {
console.log(tl.loc("DetectingPlatform"));
if (tl.osType().match(/^Win/)) {
let escapedScript = path.join(this.getCurrentDir(), 'externals', 'get-os-platform.ps1').replace(/'/g, "''");
let command = `& '${escapedScript}'`
let powershellPath = tl.which('powershell', true);
scriptRunner = tl.tool(powershellPath)
.line('-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command')
.arg(command);
}
else {
let scriptPath = path.join(this.getCurrentDir(), 'externals', 'get-os-distro.sh');
this.setFileAttribute(scriptPath, "777");
scriptRunner = tl.tool(tl.which(scriptPath, true));
}
let result: trm.IExecSyncResult = scriptRunner.execSync();
if (result.code != 0) {
throw tl.loc("getMachinePlatformFailed", result.error ? result.error.message : result.stderr);
}
let output: string = result.stdout;
let index;
if ((index = output.indexOf("Primary:")) >= 0) {
let primary = output.substr(index + "Primary:".length).split(os.EOL)[0];
osSuffix.push(primary);
console.log(tl.loc("PrimaryPlatform", primary));
}
if ((index = output.indexOf("Legacy:")) >= 0) {
let legacy = output.substr(index + "Legacy:".length).split(os.EOL)[0];
osSuffix.push(legacy);
console.log(tl.loc("LegacyPlatform", legacy));
}
if (osSuffix.length == 0) {
throw tl.loc("CouldNotDetectPlatform");
}
}
catch (ex) {
throw tl.loc("FailedInDetectingMachineArch", JSON.stringify(ex));
}
return osSuffix;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:53,代码来源:versionfetcher.ts
示例7: addDotNetCoreToolPath
function addDotNetCoreToolPath() {
try {
let globalToolPath: string = "";
if (tl.osType().match(/^Win/)) {
globalToolPath = path.join(process.env.USERPROFILE, Constants.relativeGlobalToolPath);
} else {
globalToolPath = path.join(process.env.HOME, Constants.relativeGlobalToolPath);
}
console.log(tl.loc("PrependGlobalToolPath"));
tl.mkdirP(globalToolPath);
toolLib.prependPath(globalToolPath);
} catch (error) {
//nop
console.log(tl.loc("ErrorWhileSettingDotNetToolPath", JSON.stringify(error)));
}
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:17,代码来源:dotnetcoreinstaller.ts
示例8: detectMachineOS
private detectMachineOS(): string[] {
let osSuffix = [];
if (tl.osType().match(/^Win/)) {
let primary = "win-" + os.arch();
osSuffix.push(primary);
console.log(tl.loc("PrimaryPlatform", primary));
}
else {
let scriptPath = path.join(utilities.getCurrentDir(), 'externals', 'get-os-distro.sh');
utilities.setFileAttribute(scriptPath, "777");
let scriptRunner: trm.ToolRunner = tl.tool(tl.which(scriptPath, true));
let result: trm.IExecSyncResult = scriptRunner.execSync();
if (result.code != 0) {
throw tl.loc("getMachinePlatformFailed", result.error ? result.error.message : result.stderr);
}
let output: string = result.stdout;
let index;
if ((index = output.indexOf("Primary:")) >= 0) {
let primary = output.substr(index + "Primary:".length).split(os.EOL)[0];
osSuffix.push(primary);
console.log(tl.loc("PrimaryPlatform", primary));
}
if ((index = output.indexOf("Legacy:")) >= 0) {
let legacy = output.substr(index + "Legacy:".length).split(os.EOL)[0];
osSuffix.push(legacy);
console.log(tl.loc("LegacyPlatform", legacy));
}
if (osSuffix.length == 0) {
throw tl.loc("CouldNotDetectPlatform");
}
}
return osSuffix;
}
开发者ID:grawcho,项目名称:vso-agent-tasks,代码行数:41,代码来源:dotnetcoreinstaller.ts
示例9: acquireDotNetCore
async function acquireDotNetCore(packageType: string, version: string): Promise<string> {
let downloadUrls = getDownloadUrls(packageType, version);
let downloadPath: string;
try {
// try primary url
if (!!downloadUrls[0]) {
console.log(taskLib.loc("DownloadingPrimaryUrl", downloadUrls[0]));
downloadPath = await toolLib.downloadTool(downloadUrls[0]);
}
} catch (error1) {
console.log(taskLib.loc("PrimaryUrlDownloadFailed", error1));
try {
// try secondary url
if (!!downloadUrls[1]) {
console.log(taskLib.loc("DownloadingSecondaryUrl", downloadUrls[1]));
downloadPath = await toolLib.downloadTool(downloadUrls[1]);
}
} catch (error2) {
console.log(taskLib.loc("LegacyUrlDownloadFailed", error2));
throw taskLib.loc("DownloadFailed", packageType, version);
}
}
// extract
let extPath: string;
console.log(taskLib.loc("ExtractingPackage", downloadPath));
if (taskLib.osType().match(/^Win/)) {
extPath = await toolLib.extractZip(downloadPath);
}
else {
extPath = await toolLib.extractTar(downloadPath);
}
// cache tool
let cachedToolName = getCachedToolName(packageType);
console.log(taskLib.loc("CachingTool"));
let cachedDir = await toolLib.cacheDir(extPath, cachedToolName, version);
console.log(taskLib.loc("SuccessfullyInstalled", packageType, version));
return cachedDir;
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:41,代码来源:dotnetcoreinstaller.ts
示例10: install
public async install() {
// Check cache
let toolPath: string;
let osSuffixes = this.detectMachineOS();
let parts = osSuffixes[0].split("-");
this.arch = parts.length > 1 ? parts[1] : "x64";
toolPath = this.getLocalTool();
if (!toolPath) {
// download, extract, cache
console.log(tl.loc("InstallingAfresh"));
console.log(tl.loc("GettingDownloadUrl", this.packageType, this.version));
let downloadUrls = await DotNetCoreReleaseFetcher.getDownloadUrls(osSuffixes, this.version, this.packageType);
toolPath = await this.downloadAndInstall(downloadUrls);
} else {
console.log(tl.loc("UsingCachedTool", toolPath));
}
// Prepend the tools path. instructs the agent to prepend for future tasks
toolLib.prependPath(toolPath);
try {
let globalToolPath: string = "";
if (tl.osType().match(/^Win/)) {
globalToolPath = path.join(process.env.USERPROFILE, ".dotnet\\tools");
} else {
globalToolPath = path.join(process.env.HOME, ".dotnet/tools");
}
console.log(tl.loc("PrependGlobalToolPath"));
tl.mkdirP(globalToolPath);
toolLib.prependPath(globalToolPath);
} catch (error) {
//nop
}
// Set DOTNET_ROOT for dotnet core Apphost to find runtime since it is installed to a non well-known location.
tl.setVariable('DOTNET_ROOT', toolPath);
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:39,代码来源:dotnetcoreinstaller.ts
注:本文中的vsts-task-lib/task.osType函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论