@lugia/mega-config
npm i @lugia/mega-config

@lugia/mega-config

Find and load configuration from the user

by lugia-ysstech

1.3.3 (see all)License:Apache-2.0TypeScript:Not Found
npm i @lugia/mega-config
Readme

@lugia/mega-config

Usage

import getUserConfig, {
  watchConfigs,
  unwatchConfigs,
} from '@lugia/mega-config';

// get user config
let config = null;
let userPKG = null;
let returnedWatchConfig = null;
try {
  ({ config, userPKG, watch: returnedWatchConfig } = getUserConfig({
    cwd,
    configFileName: configFile || CONFIG_FILE_NAME,
  }));
  debug(`user config: ${JSON.stringify(config)}`);
} catch (e) {
  console.error(chalk.red(e.message));
  debug(`Get ${CONFIG_FILE_NAME} config failed, watch config and reload`);

  // 监听配置项变更,然后重新执行 dev 逻辑
  watchConfigs({ cwd, configFileName: CONFIG_FILE_NAME }).on(
    'all',
    (event, path) => {
      debug(`[${event}] ${path}, unwatch and reload`);
      bs && bs.active && bs.exit(); // eslint-disable-line
      bs = null;
      unwatchConfigs();
      runDev(opts);
    },
  );
  return;
}

Downloads/wk

4

GitHub Stars

24

LAST COMMIT

2yrs ago

MAINTAINERS

6

CONTRIBUTORS

4

OPEN ISSUES

0

OPEN PRs

0
VersionTagPublished
1.3.3
latest
8mos ago
1.3.3-alpha.1
alpha
10mos ago
No alternatives found
No tutorials found
Add a tutorial