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


TypeScript js-beautify.js_beautify函數代碼示例

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


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

示例1: beautify

const generatePlugin = (protocol: any, host: any, repository: Repository) => {
  // DONE 2.3 protocol 錯誤,應該是 https
  let duplicated = parseDuplicatedInterfaces(repository)
  let editor = `${protocol}://rap2.taobao.org/repository/editor?id=${repository.id}` // [TODO] replaced by cur domain
  let result = `
/**
 * 倉庫    #${repository.id} ${repository.name}
 * 在線編輯 ${editor}
 * 倉庫數據 ${protocol}://${host}/repository/get?id=${repository.id}
 * 請求地址 ${protocol}://${host}/app/mock/${repository.id}/:method/:url
 *    或者 ${protocol}://${host}/app/mock/template/:interfaceId
 *    或者 ${protocol}://${host}/app/mock/data/:interfaceId
 */
;(function(){
  let repositoryId = ${repository.id}
  let interfaces = [
    ${repository.interfaces.map((itf: Interface) =>
      `{ id: ${itf.id}, name: '${itf.name}', method: '${itf.method}', url: '${itf.url}',
      request: ${JSON.stringify(itf.request)},
      response: ${JSON.stringify(itf.response)} }`
    ).join(',\n    ')}
  ]
  ${duplicated.length ? `console.warn('檢測到重複接口,請訪問 ${editor} 修複警告!')\n` : ''}
  let RAP = window.RAP || {
    protocol: '${protocol}',
    host: '${host}',
    interfaces: {}
  }
  RAP.interfaces[repositoryId] = interfaces
  window.RAP = RAP
})();`
  return beautify(result, { indent_size: 2 })
}
開發者ID:zerolugithub,項目名稱:rap2-delos,代碼行數:33,代碼來源:mock.ts

示例2: updateConfigFile

export function updateConfigFile(tsdConfigFile: TsdLink.TsdConfigFile){
  if(!fs.existsSync(tsdConfigFile.dir))
  {
    mkdirp.sync(tsdConfigFile.dir);
  }
  fs.writeFileSync(tsdConfigFile.path, beautify(json.stringify(tsdConfigFile.content), { indent_size: 2}) );
}
開發者ID:Cellule,項目名稱:tsd-link,代碼行數:7,代碼來源:utils.ts

示例3: beautify

            f.src.forEach(function (target) {

                // Validate file target
                if (!validate.exists(target, 'src')) { return false; }
                if (!validate.is_dir(target)) { return false; }

                // Setup actions
                actions.grunt = grunt;
                actions.options = options;
                actions.target = target;
                actions.dest = f.dest;

                // Apply the template if there is one
                if (options.template) {
                  actions.set_template(options.template);
                }

                // Generate output string
                var output_file = actions.output(options.output);

                // Validate the components of this component exist
                var parts = actions.parts();
                if (!validate.exists(parts.script, 'options.scripts in ' + target)) { return false; }
                if (!validate.exists(parts.script, 'options.styles in ' + target)) { return false; }
                if (!validate.exists(parts.script, 'options.markup in ' + target)) { return false; }

                // Generate a component from the parts
                var output = actions.combine(parts);

                // Generate output file
                output = beautify(output, { indent_size: 2 })
                fs.writeFileSync(output_file, output);

                return true;
            });
開發者ID:shadowmint,項目名稱:iwc-grunt,代碼行數:35,代碼來源:iwc.ts

示例4: addJSSuffix

export let save = (filename: string, info): void => {
  fs.writeFileSync(join(dir, addJSSuffix(filename)), jsBeautify(stringify(info)) + '\n');
};
開發者ID:SomeKittens,項目名稱:baddsert,代碼行數:3,代碼來源:badd-fs.ts


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