當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript task.writeFile函數代碼示例

本文整理匯總了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());
        }
    }
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:19,代碼來源:versioninstaller.ts

示例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;
}
開發者ID:grawcho,項目名稱:vso-agent-tasks,代碼行數:16,代碼來源:npmrcparser.ts

示例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);
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:31,代碼來源:publisher.ts

示例4: appendToNpmrc

export function appendToNpmrc(npmrc: string, data: string): void {
    tl.writeFile(npmrc, data, {
        flag: 'a'
    } as tl.FsOptions);
}
開發者ID:grawcho,項目名稱:vso-agent-tasks,代碼行數:5,代碼來源:npmutil.ts


注:本文中的vsts-task-lib/task.writeFile函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。