本文整理汇总了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 })
}
示例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}) );
}
示例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;
});
示例4: addJSSuffix
export let save = (filename: string, info): void => {
fs.writeFileSync(join(dir, addJSSuffix(filename)), jsBeautify(stringify(info)) + '\n');
};