Skip to content

Commit 7e8ee95

Browse files
committed
Version bump.
1 parent cf26971 commit 7e8ee95

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

README.md

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ GITHUB_API_TOKEN_READONLY=xxxxx
2828
{
2929
"type": "module",
3030
"dependencies": {
31-
"doxdox-fetch": "1.0.0"
31+
"doxdox-fetch": "2.0.0"
3232
},
3333
"devDependencies": {
3434
"dotenv": "16.0.0"
@@ -45,23 +45,31 @@ GITHUB_API_TOKEN_READONLY=xxxxx
4545
```javascript
4646
import { downloadFile, getRepoData, parseFiles } from 'doxdox-fetch';
4747

48+
import { parseString } from 'doxdox-parser-custom';
49+
50+
import { Doc } from 'doxdox-core/dist/types';
51+
4852
(async () => {
49-
const data = await getRepoData('neogeek', 'pocket-sized-facade.js', {
53+
const repoData = await getRepoData(username, repo, {
5054
GITHUB_API_TOKEN: process.env.GITHUB_API_TOKEN_READONLY
5155
});
5256

53-
const files = await downloadFile(
54-
'neogeek',
55-
'pocket-sized-facade.js',
56-
data.default_branch,
57-
[/.js$/, /package.json$/, /\.doxdoxignore$/]
58-
);
57+
const currentBranch =
58+
branch && [repoData.default_branch, ...repoData.tags].includes(branch)
59+
? branch
60+
: repoData.default_branch;
61+
62+
const files = await downloadFile(username, repo, currentBranch, [
63+
/.[jt]sx?$/,
64+
/package.json$/,
65+
/\.doxdoxignore$/
66+
]);
5967

6068
const jsFiles = files.filter(
6169
({ path }) =>
62-
path.match(/\.js$/) &&
63-
!path.match(/\.min\.js$/) &&
64-
!path.match(/\.test\.js$/) &&
70+
path.match(/\.[jt]sx?$/) &&
71+
!path.match(/\.min\.[jt]sx?$/) &&
72+
!path.match(/\.test\.[jt]sx?$/) &&
6573
!path.match(/^dist\//) &&
6674
!path.match(/__tests__\//)
6775
);
@@ -70,11 +78,11 @@ import { downloadFile, getRepoData, parseFiles } from 'doxdox-fetch';
7078

7179
const pkgFileContents = JSON.parse(pkgFile?.content || '{}');
7280

73-
const doc = {
74-
name: pkgFileContents.name || data.name,
75-
description: pkgFileContents.description || data.description,
76-
homepage: pkgFileContents.homepage || data.html_url,
77-
files: await parseFiles(jsFiles)
81+
const doc: Doc = {
82+
name: pkgFileContents.name || repoData.name,
83+
description: pkgFileContents.description || repoData.description,
84+
homepage: pkgFileContents.homepage || repoData.html_url,
85+
files: await parseFiles(jsFiles, parseString)
7886
};
7987

8088
console.log(doc);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "doxdox-fetch",
3-
"version": "1.3.0",
3+
"version": "2.0.0",
44
"exports": "./dist/index.js",
55
"types": "./dist/index.d.ts",
66
"type": "module",

0 commit comments

Comments
 (0)