本文整理汇总了TypeScript中azure-pipelines-task-lib/task.mkdirP函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mkdirP函数的具体用法?TypeScript mkdirP怎么用?TypeScript mkdirP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mkdirP函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _extractAdvinst
async function _extractAdvinst(sourceMsi: string): Promise<string> {
console.log(taskLib.loc("AI_ExtractTool"));
// Ensure the c:\windows\installer folder exists. MSIEXEC will fail on some clients (E.g. Hosted VS2017)
// due to the lack of this folder.
let windowsInstallerFolder = path.join(taskLib.getVariable('windir'), 'Installer');
if (!taskLib.exist(windowsInstallerFolder)) {
taskLib.debug(taskLib.loc("AI_CreateInstallerFolder"))
taskLib.mkdirP(windowsInstallerFolder);
}
let advinstWorkFolder = path.join(_getAgentTemp(), 'AdvancedInstaller');
let msiExtractionPath: string = path.join(advinstWorkFolder, 'resources');
// Create the work folder, otherwise msiexec will fail because of the log path.
if (!taskLib.exist(advinstWorkFolder))
taskLib.mkdirP(advinstWorkFolder);
let msiLogPath: string = path.join(advinstWorkFolder, 'advinst_install.log');
let msiexecArguments: string[] = ['/a', sourceMsi, 'TARGETDIR=' + msiExtractionPath, '/qn', '/l*v', msiLogPath];
let exitCode = taskLib.execSync('msiexec.exe', msiexecArguments).code;
if (exitCode != 0) {
taskLib.command('task.uploadfile', {}, msiLogPath);
return null;
}
return msiExtractionPath;
}
示例2: acquireNodeFromFallbackLocation
// For non LTS versions of Node, the files we need (for Windows) are sometimes located
// in a different folder than they normally are for other versions.
// Normally the format is similar to: https://nodejs.org/dist/v5.10.1/node-v5.10.1-win-x64.7z
// In this case, there will be two files located at:
// /dist/v5.10.1/win-x64/node.exe
// /dist/v5.10.1/win-x64/node.lib
// If this is not the structure, there may also be two files located at:
// /dist/v0.12.18/node.exe
// /dist/v0.12.18/node.lib
// This method attempts to download and cache the resources from these alternative locations.
// Note also that the files are normally zipped but in this case they are just an exe
// and lib file in a folder, not zipped.
async function acquireNodeFromFallbackLocation(version: string): Promise<string> {
// Create temporary folder to download in to
let tempDownloadFolder: string = 'temp_' + Math.floor(Math.random() * 2000000000);
let tempDir: string = path.join(taskLib.getVariable('agent.tempDirectory'), tempDownloadFolder);
taskLib.mkdirP(tempDir);
let exeUrl: string;
let libUrl: string;
try {
exeUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.exe`;
libUrl = `https://nodejs.org/dist/v${version}/win-${os.arch()}/node.lib`;
await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
}
catch (err) {
if (err['httpStatusCode'] &&
err['httpStatusCode'] === '404')
{
exeUrl = `https://nodejs.org/dist/v${version}/node.exe`;
libUrl = `https://nodejs.org/dist/v${version}/node.lib`;
await toolLib.downloadTool(exeUrl, path.join(tempDir, "node.exe"));
await toolLib.downloadTool(libUrl, path.join(tempDir, "node.lib"));
}
else {
throw err;
}
}
return await toolLib.cacheDir(tempDir, 'node', version);
}
示例3: acquireTfx
async function acquireTfx(version: string): Promise<string> {
try{
version = toolLib.cleanVersion(version);
let extPath: string;
taskLib.assertAgent('2.115.0');
extPath = taskLib.getVariable('Agent.TempDirectory');
if (!extPath) {
throw new Error('Expected Agent.TempDirectory to be set');
}
extPath = path.join(extPath, 'tfx'); // use as short a path as possible due to nested node_modules folders
taskLib.mkdirP(path.join(extPath));
const npmRunner = new tr.ToolRunner("npm");
npmRunner.arg(["install", "tfx-cli@" + version, "--prefix", extPath]);
const result = npmRunner.execSync({ failOnStdErr: false, silent: true, ignoreReturnCode: false} as tr.IExecOptions);
if (result.code === 0)
{
if (os.platform() === "win32")
{
fs.unlinkSync(path.join(extPath, "/tfx"));
}
return await toolLib.cacheDir(extPath, 'tfx', version);
}
}
catch {
return Promise.reject(new Error("Failed to install tfx"));
}
}
示例4: getTempPath
export function getTempPath(): string {
const tempNpmrcDir
= tl.getVariable('Agent.BuildDirectory')
|| tl.getVariable('Agent.TempDirectory');
const tempPath = path.join(tempNpmrcDir, 'npm');
if (tl.exist(tempPath) === false) {
tl.mkdirP(tempPath);
}
return tempPath;
}
示例5: constructor
constructor(packageType: string, installationPath: string) {
try {
tl.exist(installationPath) || tl.mkdirP(installationPath);
}
catch (ex) {
throw tl.loc("UnableToAccessPath", installationPath, JSON.stringify(ex));
}
this.packageType = packageType;
this.installationPath = installationPath;
}
示例6: getPypircPath
export function getPypircPath(): string {
let pypircPath: string;
if (tl.getVariable("PYPIRC_PATH")) {
pypircPath = tl.getVariable("PYPIRC_PATH");
}
else {
let tempPath = tl.getVariable("Agent.TempDirectory");
tempPath = path.join(tempPath, "twineAuthenticate");
tl.mkdirP(tempPath);
let savePypircPath = fs.mkdtempSync(tempPath + path.sep);
pypircPath = savePypircPath + path.sep + ".pypirc";
}
return pypircPath;
}
示例7: function
feedConnection.getCoreApi().restClient.get(packageUrl, ApiVersion, null, { responseIsCollection: false }, async function (error, status, result) {
if (!!error || status != 200) {
return reject(tl.loc("FailedToGetPackageMetadata", error));
}
var packageType = result.protocolType.toLowerCase();
var packageName = result.name;
if (packageType == "nuget") {
var getDownloadUrlPromise = getDownloadUrl(packageConnection.getCoreApi().vsoClient, feedId, packageName, version)
getDownloadUrlPromise.catch((error) => {
return reject(error)
});
var downloadUrl = await getDownloadUrlPromise;
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));
var downloadNugetPackagePromise = downloadNugetPackage(packageConnection.getCoreApi(), downloadUrl, zipLocation);
downloadNugetPackagePromise.catch((error) => {
return reject(error)
});
await downloadNugetPackagePromise;
console.log(tl.loc("ExtractingNugetPackage", packageName, unzipLocation));
var unzipPromise = unzip(zipLocation, unzipLocation);
unzipPromise.catch((error) => {
return reject(error)
});
await unzipPromise;
if (tl.exist(zipLocation)) {
tl.rmRF(zipLocation);
}
return resolve();
}
else {
return reject(tl.loc("PackageTypeNotSupported"));
}
});
示例8: 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);
tl.prependPath(globalToolPath);
} catch (error) {
//nop
console.log(tl.loc("ErrorWhileSettingDotNetToolPath", JSON.stringify(error)));
}
}
示例9: beforeEach
beforeEach(() => {
tl.mkdirP(destinationDir);
tl.mkdirP(tempDir);
});
示例10: before
before(() => {
tl.mkdirP(destinationDir);
});