本文整理汇总了TypeScript中vsts-task-lib/task.writeFile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript writeFile函数的具体用法?TypeScript writeFile怎么用?TypeScript writeFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了writeFile函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createInstallationCompleteFile
private createInstallationCompleteFile(versionInfo: VersionInfo): void {
tl.debug(tl.loc("CreatingInstallationCompeleteFile", versionInfo.getVersion(), this.packageType));
// always add for runtime as it is installed with sdk as well.
var pathToVersionCompleteFile: string = "";
if (this.packageType == utils.Constants.sdk) {
let sdkVersion = versionInfo.getVersion();
pathToVersionCompleteFile = path.join(this.installationPath, utils.Constants.relativeSdkPath, `${sdkVersion}.complete`);
tl.writeFile(pathToVersionCompleteFile, `{ "version": "${sdkVersion}" }`);
}
let runtimeVersion = versionInfo.getRuntimeVersion();
if (runtimeVersion) {
pathToVersionCompleteFile = path.join(this.installationPath, utils.Constants.relativeRuntimePath, `${runtimeVersion}.complete`);
tl.writeFile(pathToVersionCompleteFile, `{ "version": "${runtimeVersion}" }`);
}
else if (this.packageType == utils.Constants.runtime) {
throw tl.loc("CannotFindRuntimeVersionForCompletingInstallation", this.packageType, versionInfo.getVersion());
}
}
示例2: GetRegistries
export function GetRegistries(npmrc: string): string[] {
let registries: string[] = [];
let config = ini.parse(fs.readFileSync(npmrc).toString());
for (let key in config) {
let colonIndex = key.indexOf(':');
if (key.substring(colonIndex + 1).toLowerCase() === 'registry') {
config[key] = NormalizeRegistry(config[key]);
registries.push(config[key]);
}
}
// save the .npmrc with normalized registries
tl.writeFile(npmrc, ini.stringify(config));
return registries;
}
示例3: executePythonTool
var workingDirectory = tl.getInput('wd', true);
var serviceEndpointId = tl.getInput('serviceEndpoint', true);
var wheel: boolean = tl.getBoolInput('wheel');
var homedir = os.homedir();
var pypircFilePath = path.join(homedir, ".pypirc");
var pythonToolPath = tl.which('python', true);
var error = '';
//Generic service endpoint
var pythonServer = tl.getEndpointUrl(serviceEndpointId, false);
var username = tl.getEndpointAuthorizationParameter(serviceEndpointId, 'username', false);
var password = tl.getEndpointAuthorizationParameter(serviceEndpointId, 'password', false);
//Create .pypirc file
var text = util.format("[distutils] \nindex-servers =\n pypi \n[pypi] \nrepository=%s \nusername=%s \npassword=%s", pythonServer, username, password);
tl.writeFile(pypircFilePath, text, 'utf8');
(async () => {
//PyPI upload
try{
tl.cd(workingDirectory);
await executePythonTool("-m pip install twine --user");
await executePythonTool("setup.py sdist");
if(wheel){
await executePythonTool("-m pip install wheel --user");
await executePythonTool("setup.py bdist_wheel --universal");
}
await executePythonTool("-m twine upload dist/*");
}
catch(err){
tl.setResult(tl.TaskResult.Failed, error);
示例4: appendToNpmrc
export function appendToNpmrc(npmrc: string, data: string): void {
tl.writeFile(npmrc, data, {
flag: 'a'
} as tl.FsOptions);
}