Skip to content

Commit

Permalink
Merge branch 'main' into versionCtrl
Browse files Browse the repository at this point in the history
  • Loading branch information
mAmineChniti authored Aug 12, 2024
2 parents 57a3698 + 13dad24 commit 15da50c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ Make sure you have some understanding of extension development. Here are some re

- [Chrome](https://developer.chrome.com/docs/extensions/mv3/getstarted/development-basics/)
- [Firefox](https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension)
- Windows Users
- Until [this](https://github.com/oven-sh/bun/issues/43) is resolved, Bun is not supported on Windows. [WSL](https://learn.microsoft.com/en-us/windows/wsl/install) is a workaround.
- Or use the [Node.js + npm version](https://github.com/AminoffZ/catonaut-node) of this template

## 🛠️ Quick Setup

Expand Down
23 changes: 11 additions & 12 deletions build-tools/extract-inline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* https://github.com/withastro/roadmap/discussions/377
*/

import { join } from 'path';
import { Glob } from 'bun';
import { readFile, writeFile } from 'fs/promises';
import { join } from 'path';
import { djb2 } from './hash';
import glob from 'tiny-glob';

/**
* Remove inline scripts and styles from the generated HTML files.
Expand All @@ -18,18 +18,17 @@ async function removeInlineScriptAndStyle(directory: string) {
console.log('Removing Inline Scripts and Styles');
const scriptRegx = /<script[^>]*>([\s\S]+?)<\/script>/g;
const styleRegx = /<style[^>]*>([\s\S]+?)<\/style>/g;
const files = await glob('**/*.html', {
const glob = new Glob('**/*.html');

for await (const file of glob.scan({
cwd: directory,
dot: true,
absolute: false,
filesOnly: true,
});

console.log(`Found ${files.length} files`);

for (const file of files.map((f) => join(directory, f))) {
console.log(`Edit file: ${file}`);
let f = await readFile(file, { encoding: 'utf-8' });
})) {
const filePath = join(directory, file);
// console.log(`Found ${files.length} files`);
console.log(`Edit file: ${filePath}`);
let f = await readFile(filePath, { encoding: 'utf-8' });

let script;
while ((script = scriptRegx.exec(f))) {
Expand Down Expand Up @@ -62,7 +61,7 @@ async function removeInlineScriptAndStyle(directory: string) {
console.log(`Inline style extracted and saved at: ${directory}${fn}`);
}

await writeFile(file, f);
await writeFile(filePath, f);
}
}

Expand Down
Empty file modified bun.lockb
100644 → 100755
Empty file.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"chalk": "4.1.2",
"eslint": "^8.57.0",
"imagemagick": "^0.1.3",
"prettier": "^3.0.3",
"tiny-glob": "^0.2.9"
"prettier": "^3.0.3"
},
"peerDependencies": {
"typescript": "^5.0.0"
Expand Down

0 comments on commit 15da50c

Please sign in to comment.