refactor: ♻️ move function

This commit is contained in:
Guz013
2023-08-03 10:55:56 -03:00
parent 8c1e721346
commit f24aba4f8e

View File

@@ -35,32 +35,6 @@ export default class Cli {
this.debug = options.debug ?? this.debug;
}
/**
* @param {import('./types').Package} pkg - The package to detect configs
* @returns {import('./types').Package['config']} - Detected configs record
*/
detectConfig(pkg) {
const spinner = createSpinner(`Configuring ${c.bold(c.blue(pkg.name))}`);
spinner.start();
/** @type {import('./types').Package['config']} */
const pkgConfig = {};
for (const config of this.configs) {
pkgConfig[config.name] = this.detectOptions(
pkg,
config.options,
config.type === 'single',
spinner,
);
spinner.update({ text: `Configuring ${c.bold(c.blue(pkg.name))}${c.dim(`: config ${config.name}`)}` });
}
spinner.success({ text: `Configuring ${c.bold(c.blue(pkg.name))}` });
return pkgConfig;
}
/**
* @param {import('./types').Package} pkg - Package to detect from
* @param {import('./types').Config['options']} options - Options to be passed
@@ -110,6 +84,32 @@ export default class Cli {
return detectedOptions;
}
/**
* @param {import('./types').Package} pkg - The package to detect configs
* @returns {import('./types').Package['config']} - Detected configs record
*/
detectConfig(pkg) {
const spinner = createSpinner(`Configuring ${c.bold(c.blue(pkg.name))}`);
spinner.start();
/** @type {import('./types').Package['config']} */
const pkgConfig = {};
for (const config of this.configs) {
pkgConfig[config.name] = this.detectOptions(
pkg,
config.options,
config.type === 'single',
spinner,
);
spinner.update({ text: `Configuring ${c.bold(c.blue(pkg.name))}${c.dim(`: config ${config.name}`)}` });
}
spinner.success({ text: `Configuring ${c.bold(c.blue(pkg.name))}` });
return pkgConfig;
}
async run() {
const workspace = this.#workspace ?? await new Workspace(this.dir).get();