mirror of
https://github.com/jlengrand/open-wc.git
synced 2026-03-10 08:31:19 +00:00
fix: update/insert readme open-wc header via script
This commit is contained in:
33
scripts/insert-header.js
Executable file
33
scripts/insert-header.js
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/* eslint-disable consistent-return, no-console */
|
||||
const fs = require('fs');
|
||||
|
||||
function escapeRegExp(text) {
|
||||
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
}
|
||||
|
||||
const filePath = `${process.cwd()}/README.md`;
|
||||
const findPattern = escapeRegExp('[//]: # (AUTO INSERT HEADER PREPUBLISH)');
|
||||
const text = `
|
||||
> Part of Open Web Components [open-wc](https://github.com/open-wc/open-wc/)
|
||||
|
||||
Open Web Components provides a set of defaults, recommendations and tools to help facilitate your web component project. Our recommendations include: developing, linting, testing, building, tooling, demoing, publishing and automating.
|
||||
|
||||
[](https://circleci.com/gh/open-wc/open-wc)
|
||||
[](https://www.browserstack.com/automate/public-build/M2UrSFVRang2OWNuZXlWSlhVc3FUVlJtTDkxMnp6eGFDb2pNakl4bGxnbz0tLUE5RjhCU0NUT1ZWa0NuQ3MySFFWWnc9PQ==--86f7fac07cdbd01dd2b26ae84dc6c8ca49e45b50)
|
||||
[](https://renovatebot.com/)
|
||||
`.trim();
|
||||
|
||||
fs.readFile(filePath, 'utf8', (readError, data) => {
|
||||
if (readError) {
|
||||
return console.log(readError);
|
||||
}
|
||||
|
||||
const result = data.replace(new RegExp(findPattern), text);
|
||||
fs.writeFile(filePath, result, 'utf8', writeError => {
|
||||
if (writeError) {
|
||||
return console.log(writeError);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user