MCPcopy Create free account
hub / github.com/compat-table/compat-table / handle

Function handle

build.js:396–419  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

394
395
396function handle(options) {
397 var skeleton = fs.readFileSync(__dirname + path.sep + options.skeleton_file, 'utf-8');
398 var html = dataToHtml(skeleton, options.browsers, options.tests, options.compiler);
399
400 var result = replaceAndIndent(html, [
401 ["<!-- NAME -->", [options.name]],
402 ["<!-- URL -->", [options.name.link(options.url)]],
403 ["<!-- POLYFILLS -->", !options.polyfills ? [] : options.polyfills.map(function (e) {
404 return '<script>' + fs.readFileSync(__dirname + path.sep + e, 'utf-8').replace(/<(?=\/script>)/g,'\\u003c') + '</script>\n';
405 })],
406 ]).replace(/\t/g, ' ');
407
408 var target_file = __dirname + path.sep + options.target_file;
409 var old_result;
410 try {
411 old_result = fs.readFileSync(target_file, 'utf-8');
412 } catch (e) {}
413 if (old_result === result) {
414 console.log('[' + options.name + '] ' + options.target_file + ' not changed');
415 } else {
416 fs.writeFileSync(target_file, result, 'utf-8');
417 console.log('[' + options.name + '] Write to file ' + options.target_file);
418 }
419}
420
421function dataToHtml(skeleton, rawBrowsers, tests, compiler) {
422 var $ = cheerio.load(skeleton);

Callers 1

build.jsFile · 0.85

Calls 2

dataToHtmlFunction · 0.85
replaceAndIndentFunction · 0.85

Tested by

no test coverage detected