All files / src/commands/features features.disable.command.js

54.16% Statements 13/24
100% Branches 1/1
0% Functions 0/1
54.16% Lines 13/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25193x 193x 193x 193x 193x 193x 193x 193x 193x 193x 193x                       193x 193x  
import { EXPERIMENTAL_FEATURES, setFeature } from '../../config/features.js';
import { defineCommand } from '../../lib/define-command.js';
import { Logger } from '../../logger.js';
import { featuresArg } from './features.args.js';
 
export const featuresDisableCommand = defineCommand({
  description: 'Disable experimental features',
  since: '3.11.0',
  options: {},
  args: [featuresArg],
  async handler(_options, features) {
    const availableFeatures = Object.keys(EXPERIMENTAL_FEATURES);

    const unknownFeatures = features.filter((feature) => !availableFeatures.includes(feature));
    if (unknownFeatures.length > 0) {
      throw new Error(`Unavailable feature(s): ${unknownFeatures.join(', ')}`);
    }

    for (const featureName of features) {
      await setFeature(featureName, false);
      Logger.println(`Experimental feature '${featureName}' disabled`);
    }
  },
});