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


TypeScript indent-string.default函數代碼示例

本文整理匯總了TypeScript中indent-string.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: if

				vscode.window.activeTextEditor.edit((editBuilder: vscode.TextEditorEdit) => {
					if (startLine < 0) {
						//If the function declaration is on the first line in the editor we need to set startLine to first line
						//and then add an extra newline at the end of the text to insert
						startLine = 0;
						textToInsert = textToInsert + '\n';
					}
					//Check if there is any text on startLine. If there is, add a new line at the end
					var lastCharIndex = vscode.window.activeTextEditor.document.lineAt(startLine).text.length;
					var pos:vscode.Position;
					if ((lastCharIndex > 0) && (startLine !=0)) {
						pos = new vscode.Position(startLine, lastCharIndex);
						textToInsert = '\n' + textToInsert; 	
					}
					else {
						pos = new vscode.Position(startLine, 0);
					}
					var line:string = vscode.window.activeTextEditor.document.lineAt(selection.start.line).text;
					var firstNonWhiteSpace :number = vscode.window.activeTextEditor.document.lineAt(selection.start.line).firstNonWhitespaceCharacterIndex;
					var numIndent : number = 0;
					var tabSize : number = vscode.window.activeTextEditor.options.tabSize;
					var stringToIndent: string = '';
					for (var i = 0; i < firstNonWhiteSpace; i++) {
						if (line.charAt(i) == '\t') {
							stringToIndent = stringToIndent + '\t';
						}
						else if (line.charAt(i) == ' ') {
							stringToIndent = stringToIndent + ' ';
						}
					}					
					textToInsert = indentString(textToInsert, stringToIndent, 1);
					editBuilder.insert(pos, textToInsert);
				}).then(() => {
開發者ID:epaezrubio,項目名稱:vscode-comment,代碼行數:33,代碼來源:extension.ts

示例2: testGroups

    async testGroups(): Promise<ITestGroupResult[]> {
        const groupResults: ITestGroupResult[] = []

        for (const group of this.testRepo.groups) {
            const testResults: ITestResult[] = []

            for (const test of group.tests) {
                let stdout = ''
                let stderr = ''
                let success = false

                try {
                    const res = await exec(test.file)
                    console.log(`${chalk.green('✔️')} ${group.name}/${test.name}`)
                    stdout = res.stdout
                    stderr = res.stderr
                    success = true
                } catch (e) {
                    console.log(`${chalk.red('❌')} ${test.name} ${test.file}`)
                    stdout = e.stdout
                    stderr = e.stderr
                } finally {
                    if (stdout != '')
                        console.log(indent(`stdout:\n${indent(stdout, 4)}`, 4))
                    if (stderr != '')
                        console.log(indent(`stderr:\n${indent(chalk.red(stderr), 4)}`, 4))
                }

                testResults.push({
                    stderr,
                    stdout,
                    success,
                    test,
                })
            }
            groupResults.push({
                testGroup: group,
                testResults,
            })
        }
        return groupResults
    }
開發者ID:ahormazabal,項目名稱:rundeck,代碼行數:42,代碼來源:test-runner.ts

示例3: runCommand

export async function runCommand(command: ICommand, config: ICommandConfig) {
  try {
    log.write(
      chalk.bold(
        `Running [${chalk.green(command.name)}] command from [${chalk.yellow(config.rootPath)}]:\n`
      )
    );

    const projectPaths = getProjectPaths(config.rootPath, config.options as IProjectPathOptions);

    const projects = await getProjects(config.rootPath, projectPaths, {
      exclude: toArray(config.options.exclude),
      include: toArray(config.options.include),
    });

    if (projects.size === 0) {
      log.write(
        chalk.red(
          `There are no projects found. Double check project name(s) in '-i/--include' and '-e/--exclude' filters.\n`
        )
      );
      return process.exit(1);
    }

    const projectGraph = buildProjectGraph(projects);

    log.write(chalk.bold(`Found [${chalk.green(projects.size.toString())}] projects:\n`));
    log.write(renderProjectsTree(config.rootPath, projects));

    await command.run(projects, projectGraph, config);
  } catch (e) {
    log.write(chalk.bold.red(`\n[${command.name}] failed:\n`));

    if (e instanceof CliError) {
      const msg = chalk.red(`CliError: ${e.message}\n`);
      log.write(wrapAnsi(msg, 80));

      const keys = Object.keys(e.meta);
      if (keys.length > 0) {
        const metaOutput = keys.map(key => {
          const value = e.meta[key];
          return `${key}: ${value}`;
        });

        log.write('Additional debugging info:\n');
        log.write(indentString(metaOutput.join('\n'), 3));
      }
    } else {
      log.write(e.stack);
    }

    process.exit(1);
  }
}
開發者ID:Jaaess,項目名稱:kibana,代碼行數:54,代碼來源:run.ts


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