-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72414b0
commit f385e7d
Showing
5 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env node | ||
|
||
const table = require("markdown-table"); | ||
const fs = require("fs"); | ||
const data = require("../src/data.json"); | ||
|
||
const headers = [ | ||
"Package", | ||
"Version", | ||
"Automatic Vendor Prefixing", | ||
"Pseudo Classes", | ||
"Media Queries", | ||
"Styles As Object Literals", | ||
"Extract CSS File" | ||
]; | ||
|
||
const link = obj => `[${obj.text}](${obj.href})`; | ||
const links = objs => objs.map(link).join(" + "); | ||
const version = obj => obj; | ||
const symbol = obj => (obj === true ? "✓" : ""); | ||
|
||
const row = obj => | ||
headers.map(header => { | ||
if (header === "Package") { | ||
return links(obj[header]); | ||
} else if (header === "Version") { | ||
return version(obj[header]); | ||
} else { | ||
return symbol(obj[header]); | ||
} | ||
}); | ||
|
||
const rows = data.rows.map(row); | ||
rows.unshift(headers); | ||
|
||
let text = fs.readFileSync("../README.md", "utf8"); | ||
|
||
if (text.indexOf("<!-- autogenerated table start -->") === -1) { | ||
console.log( | ||
`Error! Please, place tags around the table \n<!-- autogenerated table start --> table <!-- autogenerated table end -->` | ||
); | ||
process.exit(1); | ||
} | ||
|
||
text = text.replace( | ||
/<!-- autogenerated table start -->[\s\S]*?<!-- autogenerated table end -->/, | ||
`<!-- autogenerated table start -->\n${table( | ||
rows | ||
)}\n<!-- autogenerated table end -->` | ||
); | ||
fs.writeFileSync("../README.md", text, "utf8"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters