md-hopper 1.0.0-alpha.2 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ export interface Settings {
3
3
  include: string[];
4
4
  exclude: string[];
5
5
  filenames: string[];
6
+ input: string;
6
7
  output: string;
7
8
  depth: number;
8
9
  }
@@ -6,7 +6,7 @@ export const warn = (...args) => {
6
6
  console.log(chalk.hex('#FFA500')(...args));
7
7
  };
8
8
  export const info = (...args) => {
9
- console.log(chalk.blue(...args));
9
+ console.log(chalk.hex('#77CFF5')(...args));
10
10
  };
11
11
  export const error = (...args) => {
12
12
  console.log(chalk.red(...args));
@@ -1,4 +1,5 @@
1
1
  export declare const getExecDir: () => string;
2
+ export declare const getParseDirPath: (path: string) => string;
2
3
  export declare const getDir: (path: string) => string;
3
4
  export declare const DEPTH_TYPES: {
4
5
  ancestor: string;
@@ -1,5 +1,6 @@
1
1
  import { parse, relative } from 'path';
2
2
  export const getExecDir = () => process.cwd();
3
+ export const getParseDirPath = (path) => parse(path).dir;
3
4
  export const getDir = (path) => {
4
5
  return parse(path).dir;
5
6
  };
@@ -12,6 +12,7 @@ export const DEFAULT_SETTINGS = Object.freeze({
12
12
  include: [],
13
13
  filenames: [DEFAULT_MD_FILE_NAME],
14
14
  output: DEFAULT_MD_FILE_NAME,
15
+ input: '.',
15
16
  depth: 0,
16
17
  });
17
18
  export const parse = (txt) => {
@@ -3,7 +3,7 @@ import { join } from 'path';
3
3
  import { getAllFiles } from '../../../_internal/utils/fs.js';
4
4
  import { info, warn, success } from '../../../_internal/utils/log.js';
5
5
  import { getParam, getTitle, replace } from '../../../_internal/utils/md.js';
6
- import { getExecDir } from '../../../_internal/utils/path.js';
6
+ import { getExecDir, getParseDirPath } from '../../../_internal/utils/path.js';
7
7
  import { getDir, getDepthType, DEPTH_TYPES } from '../../../_internal/utils/path.js';
8
8
  const replacePath = (str) => str.replace(/\/{2,}/, '/');
9
9
  const splitComma = (str, alternative) => (str ? str.split(',') : null) || alternative;
@@ -13,6 +13,7 @@ const mergeConfig = ({ options, settings }) => {
13
13
  exclude: splitComma(options.exclude, settings.exclude),
14
14
  include: splitComma(options.include, settings.include),
15
15
  filenames: splitComma(options.filenames, settings.filenames),
16
+ input: getParseDirPath(options.input || '.'),
16
17
  output: options.output || settings.output,
17
18
  depth: Number(options.depth) || settings.depth,
18
19
  };
@@ -80,17 +81,19 @@ export const action = async (args) => {
80
81
  info('exec dir path', execDir);
81
82
  const config = mergeConfig(args);
82
83
  info('settings', JSON.stringify(config, null, 2));
84
+ const targetDir = join(execDir, config.input);
85
+ info('target dir', targetDir);
83
86
  const skipHidden = config['skip-hidden'] ? ['**/.*/**/*', '**/.*'] : [];
84
87
  const exclude = [
85
88
  '**/node_modules/.*/*',
86
89
  '**/node_modules/**/*',
87
90
  ...skipHidden,
88
- ...config.exclude.map(path => replacePath(`${execDir}/${path}`)),
91
+ ...config.exclude.map(path => replacePath(join(targetDir, path))),
89
92
  ];
90
93
  info('exclude', JSON.stringify(exclude, null, 2));
91
- const include = config.include.map(path => replacePath(`${execDir}/${path}`));
94
+ const include = config.include.map(path => replacePath(join(targetDir, path)));
92
95
  info('include', JSON.stringify(include, null, 2));
93
- const paths = getAllFiles(execDir, {
96
+ const paths = getAllFiles(targetDir, {
94
97
  include,
95
98
  exclude,
96
99
  ...(config.depth >= 1 ? { depth: config.depth } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md-hopper",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.3",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "bin": {