Skip to content

Commit

Permalink
chore: changelog template
Browse files Browse the repository at this point in the history
  • Loading branch information
jeasonstudio committed Jan 19, 2024
1 parent 8951973 commit 5150a53
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"changelog": "@changesets/changelog-github",
"commit": true,
"fixed": [],
"linked": [],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"type-fest": "^4.9.0"
},
"devDependencies": {
"@changesets/changelog-git": "^0.2.0",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.11",
Expand Down
61 changes: 58 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/tests/traverse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
serialize,
traverse,
visit,
visitNodes,
} from '../traverse';

test('traverse', () => {
Expand Down Expand Up @@ -52,6 +53,8 @@ contract HelloWorld {
expect(p.getFlattenParents(1).length).toBe(1);
}
});

expect(visitNodes(ast, (p) => p.depth === 1).length).toBe(2);
});

test('selector', () => {
Expand Down
13 changes: 13 additions & 0 deletions src/traverse/visit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,16 @@ export const visit = <T extends SyntaxNode>(ast: T, handlers: VisitHandlers): vo
handlers.exit?.(p);
});
};

export const visitNodes = <T extends SyntaxNode = SyntaxNode>(
ast: SyntaxNode,
callback: (p: TraversePath) => boolean,
): T[] => {
const nodes: T[] = [];
visit(ast, {
enter(path) {
if (callback(path)) nodes.push(path.node as any);
},
});
return nodes;
};

0 comments on commit 5150a53

Please sign in to comment.