本文整理汇总了TypeScript中azure-pipelines-task-lib/task.checkPath函数的典型用法代码示例。如果您正苦于以下问题:TypeScript checkPath函数的具体用法?TypeScript checkPath怎么用?TypeScript checkPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkPath函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
var jarsigning = (fn: string) => {
// file must exist
tl.checkPath(fn, 'file to sign');
var jarsigner = tl.which("jarsigner", false);
if (!jarsigner) {
var java_home = tl.getVariable('JAVA_HOME');
if (!java_home) {
throw tl.loc('JavaHomeNotSet');
}
jarsigner = tl.resolve(java_home, 'bin', 'jarsigner');
}
var jarsignerRunner = tl.tool(jarsigner);
// Get keystore file path for signing
var keystoreFile = tl.getTaskVariable('KEYSTORE_FILE_PATH');
// Get keystore alias
var keystoreAlias = tl.getInput('keystoreAlias', true);
var keystorePass = tl.getInput('keystorePass', false);
var keyPass = tl.getInput('keyPass', false);
var jarsignerArguments = tl.getInput('jarsignerArguments', false);
jarsignerRunner.arg(['-keystore', keystoreFile]);
if (keystorePass) {
jarsignerRunner.arg(['-storepass', keystorePass]);
}
if (keyPass) {
jarsignerRunner.arg(['-keypass', keyPass]);
}
if (jarsignerArguments) {
jarsignerRunner.line(jarsignerArguments);
}
var unsignedFn = fn + ".unsigned";
var success = tl.mv(fn, unsignedFn, '-f', false);
jarsignerRunner.arg(['-signedjar', fn, unsignedFn, keystoreAlias]);
return jarsignerRunner.exec(null);
}
示例2: findAndroidTool
const apksigning = (fn: string) => {
// file must exist
tl.checkPath(fn, 'file to sign');
let apksigner = tl.getInput('apksignerLocation', false);
// if the tool path is not set, let's find one (anyone) from the SDK folder
if (!apksigner) {
apksigner = findAndroidTool('apksigner');
}
const apksignerRunner = tl.tool(apksigner);
// Get keystore file path for signing
const keystoreFile = tl.getTaskVariable('KEYSTORE_FILE_PATH');
// Get keystore alias
const keystoreAlias = tl.getInput('keystoreAlias', true);
const keystorePass = tl.getInput('keystorePass', false);
const keyPass = tl.getInput('keyPass', false);
const apksignerArguments = tl.getInput('apksignerArguments', false);
apksignerRunner.arg(['sign', '--ks', keystoreFile]);
if (keystorePass) {
apksignerRunner.arg(['--ks-pass', 'pass:' + keystorePass]);
}
if (keystoreAlias) {
apksignerRunner.arg(['--ks-key-alias', keystoreAlias]);
}
if (keyPass) {
apksignerRunner.arg(['--key-pass', 'pass:' + keyPass]);
}
if (apksignerArguments) {
apksignerRunner.line(apksignerArguments);
}
apksignerRunner.arg([fn]);
return apksignerRunner.exec(null);
};
示例3: registerAdvinst
async function registerAdvinst(toolRoot: string, license: string): Promise<void> {
if (!license)
return;
console.log(taskLib.loc("AI_RegisterTool"))
let toolVersion: string = fileInfo.getFileVersion(path.join(toolRoot, advinstToolExecutable));
let registrationCmd: string = "/RegisterCI";
if (cmpVer.lt(advinstRegVersionSwitch, toolVersion) < 0) {
registrationCmd = "/Register";
}
let execResult = taskLib.execSync(path.join(toolRoot, advinstToolCmdLineUtility), [registrationCmd, license]);
if (execResult.code != 0) {
throw new Error(taskLib.loc("AI_RegisterToolFailed", execResult.stdout));
}
let licensePath = path.join(taskLib.getVariable('ProgramData'), advinstLicenseSubPath);
taskLib.checkPath(licensePath, taskLib.loc("AI_AdvinstLicenseFile"));
taskLib.setVariable('advinst.cleanup', 'true');
}
示例4: if
void common.runTfx(async tfx => {
let cleanupTfxArgs: () => void;
try {
tfx.arg(["extension", "publish", "--json", "--no-color"]);
const outputVariable = tl.getInput("outputVariable", false);
common.setTfxMarketplaceArguments(tfx);
// Read file type
const fileType = tl.getInput("fileType", true);
let vsixOutput;
if (fileType === "manifest") {
// Set tfx manifest arguments
cleanupTfxArgs = common.validateAndSetTfxManifestArguments(tfx);
// Update tasks version if needed
await common.checkUpdateTasksManifests();
} else {
// Set vsix file argument
let vsixFilePattern = tl.getPathInput("vsixFile", true);
let matchingVsixFile: string[];
if (vsixFilePattern.indexOf("*") >= 0 || vsixFilePattern.indexOf("?") >= 0) {
tl.debug("Pattern found in vsixFile parameter");
matchingVsixFile = tl.findMatch(tl.getInput("cwd", false) || process.cwd(), vsixFilePattern);
}
else {
tl.debug("No pattern found in vsixFile parameter");
matchingVsixFile = [vsixFilePattern];
}
if (!matchingVsixFile || matchingVsixFile.length === 0) {
tl.setResult(tl.TaskResult.Failed, `Found no vsix files matching: ${vsixFilePattern}.`);
return false;
}
if (matchingVsixFile.length !== 1) {
tl.setResult(tl.TaskResult.Failed, `Found multiple vsix files matching: ${vsixFilePattern}.`);
return false;
}
const vsixFile = matchingVsixFile[0];
tl.checkPath(vsixFile, "vsixPath");
vsixOutput = tl.getVariable("System.DefaultWorkingDirectory");
const publisher = tl.getInput("publisherId", false);
const extensionId = tl.getInput("extensionId", false);
const extensionTag = tl.getInput("extensionTag", false);
const extensionName = tl.getInput("extensionName", false);
const extensionVisibility = tl.getInput("extensionVisibility", false) || "";
const extensionPricing = tl.getInput("extensionPricing", false);
const extensionVersion = common.getExtensionVersion();
const updateTasksId = tl.getBoolInput("updateTasksId", false);
const updateTasksVersion = tl.getBoolInput("updateTasksVersion", false);
if (publisher
|| extensionId
|| extensionTag
|| extensionName
|| (extensionPricing && extensionPricing !== "default")
|| (extensionVisibility && extensionVisibility !== "default")
|| extensionVersion
|| updateTasksId ) {
tl.debug("Start editing of VSIX");
const ve = new vsixeditor.VSIXEditor(vsixFile, vsixOutput);
ve.startEdit();
if (publisher) { ve.editPublisher(publisher); }
if (extensionId) { ve.editId(extensionId); }
if (extensionTag) { ve.editIdTag(extensionTag); }
if (extensionName) { ve.editExtensionName(extensionName); }
if (extensionVisibility) { ve.editExtensionVisibility(extensionVisibility); }
if (extensionPricing) { ve.editExtensionPricing(extensionPricing); }
if (extensionVersion) {
ve.editVersion(extensionVersion);
ve.editUpdateTasksVersion(updateTasksVersion);
}
if (updateTasksId) {
ve.editUpdateTasksId(updateTasksId);
}
const vsixGeneratedFile = await ve.endEdit();
tfx.arg(["--vsix", vsixGeneratedFile]);
vsixOutput = vsixGeneratedFile;
}
else {
vsixOutput = vsixFile;
tfx.arg(["--vsix", vsixOutput]);
}
}
// Share with
const shareWith = tl.getDelimitedInput("shareWith", ",", false).map((value) => { return value.trim(); });
const extensionVisibility = tl.getInput("extensionVisibility", false) || "";
const connectTo = tl.getInput("connectTo", true);
if (shareWith) {
//.........这里部分代码省略.........
示例5: resolveWildcardPath
export function resolveWildcardPath(
pattern: string,
allowEmptyWildcardMatch?: boolean,
includeFolders?: boolean): string[] {
const isWindows = tl.osType() === "Windows_NT";
// Resolve files for the specified value or pattern
let filesList: string[];
// empty patterns match nothing (otherwise they will effectively match the current directory)
if (!pattern) {
filesList = [];
}
else if (pattern.indexOf("*") === -1 && pattern.indexOf("?") === -1) {
// No pattern found, check literal path to a single file
tl.checkPath(pattern, "files");
// Use the specified single file
filesList = [pattern];
} else {
const firstWildcardIndex = function (str) {
const idx = str.indexOf("*");
const idxOfWildcard = str.indexOf("?");
if (idxOfWildcard > -1) {
return (idx > -1) ?
Math.min(idx, idxOfWildcard) : idxOfWildcard;
}
return idx;
};
// Find app files matching the specified pattern
tl.debug("Matching glob pattern: " + pattern);
// First find the most complete path without any matching patterns
const idx = firstWildcardIndex(pattern);
tl.debug("Index of first wildcard: " + idx);
// include the wildcard character because:
// dirname(c:\foo\bar\) => c:\foo (which will make find() return a bunch of stuff we know we'll discard)
// dirname(c:\foo\bar\*) => c:\foo\bar
const findPathRoot = path.dirname(pattern.slice(0, idx + 1));
tl.debug("find root dir: " + findPathRoot);
// Now we get a list of all files under this root
const allFiles = tl.find(findPathRoot);
// Now matching the pattern against all files
// Turn off a bunch of minimatch features to replicate the behavior of Find-Files in the old PowerShell tasks
const patternFilter = tl.filter(
pattern, {
matchBase: true,
nobrace: true,
noext: true,
nocomment: true,
nonegate: true,
nocase: isWindows,
dot: isWindows,
});
filesList = allFiles.filter(patternFilter);
// Avoid matching anything other than files
if (!includeFolders) {
filesList = filesList.filter((x) => tl.stats(x).isFile());
} else {
filesList = filesList.filter((x) => tl.stats(x).isFile() || tl.stats(x).isDirectory());
}
// Fail if no matching .sln files were found
if (!allowEmptyWildcardMatch && (!filesList || filesList.length === 0)) {
throw new Error(tl.loc("Error_NoMatchingFilesFoundForPattern", pattern));
}
}
if (!isWindows) {
return filesList;
}
else {
return filesList.map((file) => file.split("/").join("\\"));
}
}
示例6: runBuild
export async function runBuild(): Promise<void> {
const aipPath: string = taskLib.getPathInput('AipPath', true, false);
let aipBuild: string = taskLib.getInput('AipBuild');
let aipPackageName: string = taskLib.getInput('AipPackageName');
let aipOutputFolder: string = taskLib.getInput('AipOutputFolder');
if (aipOutputFolder == taskLib.getVariable('BUILD_SOURCESDIRECTORY')) {
taskLib.debug("Reset AipOutputFolder. OLD: $aipOutputFolder NEW:(empty).");
aipOutputFolder = ""
}
const aipExtraCommands: string[] = taskLib.getDelimitedInput('AipExtraCommands', '\r\n');
const aipResetDigSign: boolean = taskLib.getBoolInput('AipResetDigSign');
// Log input parameters
if (aipBuild == null) {
aipBuild = '';
}
taskLib.debug(taskLib.loc("AI_StartTaskLog"));
taskLib.debug("aipPath = " + aipPath);
taskLib.debug("aipBuild = " + aipBuild);
taskLib.debug("aipPackageName = " + aipPackageName);
taskLib.debug("aipOutputFolder = " + aipOutputFolder);
taskLib.debug("aipExtraCommands = " + aipExtraCommands);
taskLib.debug("aipResetDigSign = " + aipResetDigSign);
// Validate "aipPath" input parameter.
taskLib.checkPath(aipPath, aipPath);
// Validate advinst tool path
const advinstToolPath: string = await getAdvinstComTool();
if (null == advinstToolPath) {
throw new Error(taskLib.loc("AI_AdvinstNotFoundErr"));
}
// Compute the advinst commands
let advinstCommands: string[] = [];
if (aipPackageName) {
advinstCommands.push(`SetPackageName \"${aipPackageName}\" -buildname \"${aipBuild}\"`);
}
if (aipOutputFolder) {
advinstCommands.push(`SetOutputLocation -path \"${aipOutputFolder}\" -buildname \"${aipBuild}\"`);
}
if (aipResetDigSign) {
advinstCommands.push('ResetSig');
}
if (aipExtraCommands.length > 0) {
advinstCommands = advinstCommands.concat(aipExtraCommands);
}
advinstCommands.push(aipBuild ? `Build -buildslist \"${aipBuild}\"` : `Build`);
//Execute the commands
try {
var commandsFilePath = getCommandsFile(advinstCommands);
const advinstCmdLineArgs: string[] = ['/execute', `${aipPath}`, `${commandsFilePath}`];
let result = taskLib.execSync(advinstToolPath, advinstCmdLineArgs);
if (result.code != 0) {
throw new Error(taskLib.loc("AI_ExecFailedErr", result.stdout));
}
}
finally {
if (commandsFilePath) {
taskLib.rmRF(commandsFilePath);
}
}
}