Skip to content

Commit

Permalink
add open script
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Jan 1, 2024
1 parent f16a488 commit 7390e8c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"test-browser": "node ./test/test.js",
"test": "npm run test-browser && npm run test-node && npm run build-docs",
"dev": "sf d v8",
"open": "node ./scripts/open.js",
"patch": "npm run build && sf publish patch -r"
},
"workspaces": [
Expand Down
23 changes: 23 additions & 0 deletions scripts/open.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const fs = require('fs');
const path = require('path');

const openUrl = async (p) => {
const open = await import('open');
await open.default(p);
};

const main = async () => {
const list = fs.readdirSync(path.resolve('docs'), {
withFileTypes: true
});
for (const item of list) {
if (item.isDirectory()) {
const indexPath = path.resolve('docs', item.name, 'index.html');
if (fs.existsSync(indexPath)) {
await openUrl(indexPath);
}
}
}
};

main();
1 change: 1 addition & 0 deletions test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"koa": "^2.15.0",
"koa-static-resolver": "^1.0.4",
"marked": "^11.1.1",
"open": "^10.0.2",
"playwright": "^1.40.1",
"rollup": "^4.9.2",
"ts-loader": "^9.5.1",
Expand Down

0 comments on commit 7390e8c

Please sign in to comment.