-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexampleCodeGenerator.js
More file actions
27 lines (20 loc) · 851 Bytes
/
Copy pathexampleCodeGenerator.js
File metadata and controls
27 lines (20 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const fs = require('fs'),
hljs = require('highlight.js'),
file = process.argv[2],
// lang = process.argv[3],
lang='html'
pathDir = "./src/assets/examples/"
htmlPath = `${pathDir}/${file}/${file}.component.html`
tsPath = `${pathDir}/${file}/${file}.component.ts`
htmlData = fs.readFileSync(htmlPath);
tsData = fs.readFileSync(tsPath);
var htmlCode = htmlData.toString();
var tsCode = tsData.toString()
// console.log(hljs.highlight('html', htmlCode).value);
// console.log(hljs.highlight('typescript', tsCode).value)
const htmlExamplePath = `${pathDir}/${file}/${file}.example.html`
const tsExamplePath = `${pathDir}/${file}/${file}.example.ts.html`
//write back to toolkit
fs.writeFileSync(htmlExamplePath, hljs.highlight('html', htmlCode).value)
fs.writeFileSync(tsExamplePath, hljs.highlight('typescript', tsCode).value)
console.log('done')