Skip to content

Commit c0f37cd

Browse files
committed
Added ignoreFiles and gitignore option to globby.
Removed getIgnoreConfigInPath utility.
1 parent f9a98d8 commit c0f37cd

File tree

3 files changed

+10
-71
lines changed

3 files changed

+10
-71
lines changed

packages/doxdox-cli/src/index.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,17 @@ import parseCmdArgs from 'parse-cmd-args';
1515
import doxdox, {
1616
findFileInPath,
1717
findParentNodeModules,
18-
getIgnoreConfigInPath,
18+
getProjectPackage,
1919
getRootDirPath,
20-
parseIgnoreConfig,
2120
loadPlugin,
22-
sanitizePath,
23-
getProjectPackage
21+
parseIgnoreConfig,
22+
sanitizePath
2423
} from 'doxdox-core';
2524

2625
import { Doc, File } from 'doxdox-core';
2726

2827
const defaultPaths = ['**/*.js'];
2928

30-
const defaultIgnorePatterns = ['!node_modules/'];
31-
3229
const helpDocs = `Usage: doxdox <path> ... [options]
3330
3431
Options:
@@ -92,13 +89,13 @@ const overridePackage = args.flags['-p'] || args.flags['--package'];
9289
}
9390

9491
const paths = await globby(
95-
(args.input ? [args.input] : defaultPaths).concat([
96-
...defaultIgnorePatterns,
97-
...parseIgnoreConfig(overrideIgnore.split(',').join(EOL)),
98-
...(await getIgnoreConfigInPath(cwd))
99-
]),
92+
(args.input ? [args.input] : defaultPaths).concat(
93+
parseIgnoreConfig(overrideIgnore.split(',').join(EOL))
94+
),
10095
{
101-
cwd
96+
cwd,
97+
ignoreFiles: ['.doxdoxignore'],
98+
gitignore: true
10299
}
103100
);
104101

packages/doxdox-core/src/utils.test.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { join } from 'path';
77
import {
88
findFileInPath,
99
findParentNodeModules,
10-
getIgnoreConfigInPath,
1110
getProjectPackage,
1211
getRootDirPath,
1312
isDirectory,
@@ -57,35 +56,6 @@ describe('utils', () => {
5756
});
5857
});
5958

60-
describe('getIgnoreConfigInPath', () => {
61-
it('find ignore config with input directory', async () => {
62-
assert.deepEqual(await getIgnoreConfigInPath('./'), [
63-
'!**/*.test.*',
64-
'!./coverage/',
65-
'!./dist/'
66-
]);
67-
});
68-
69-
it('find ignore config with input file', async () => {
70-
assert.deepEqual(await getIgnoreConfigInPath('./.doxdoxignore'), [
71-
'!**/*.test.*',
72-
'!./coverage/',
73-
'!./dist/'
74-
]);
75-
});
76-
77-
it('fail to find ignore config with input non .doxdoxignore file', async () => {
78-
assert.deepEqual(
79-
await getIgnoreConfigInPath('./jest.config.js'),
80-
[]
81-
);
82-
});
83-
84-
it('fail to find ignore config with invalid directory', async () => {
85-
assert.deepEqual(await getIgnoreConfigInPath('../testing'), []);
86-
});
87-
});
88-
8959
describe('getProjectPackage', () => {
9060
it('gets contents from project package', async () => {
9161
const { name, description, version, exports } = JSON.parse(

packages/doxdox-core/src/utils.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -76,32 +76,6 @@ export const findParentNodeModules = async (
7676
return null;
7777
};
7878

79-
/**
80-
* Return list of ignored paths and files.
81-
*
82-
* console.log(await getIgnoreConfigInPath('./'));
83-
* console.log(await getIgnoreConfigInPath('./.doxdoxignore'));
84-
* console.log(await getIgnoreConfigInPath('~/git/github/doxdox/'));
85-
*
86-
* @param {string} [input] Directory to check for ignore config file.
87-
* @return {Promise<string[]>} List of ignored paths and files.
88-
* @public
89-
*/
90-
91-
export const getIgnoreConfigInPath = async (
92-
input: string
93-
): Promise<string[]> => {
94-
const ignorePath = await findFileInPath(input, '.doxdoxignore');
95-
96-
if (ignorePath) {
97-
const ignoreContents = await fs.readFile(ignorePath, 'utf8');
98-
99-
return parseIgnoreConfig(ignoreContents);
100-
}
101-
102-
return [];
103-
};
104-
10579
/**
10680
* Returns basic information from a projects package file.
10781
*
@@ -169,9 +143,7 @@ export const isFile = async (path: string): Promise<boolean> => {
169143
/**
170144
* Parse contents of ignore file.
171145
*
172-
* console.log(await parseIgnoreConfig('./'));
173-
* console.log(await getIgnoreConfigInPath('./.doxdoxignore'));
174-
* console.log(await getIgnoreConfigInPath('~/git/github/doxdox/'));
146+
* console.log(await parseIgnoreConfig('node_modules/'));
175147
*
176148
* @param {string} [contents] Contents of ignore file.
177149
* @return {string[]} List of ignored paths and files.

0 commit comments

Comments
 (0)