All files / src/node-resolve deprecated-options.js

30.76% Statements 4/13
10% Branches 1/10
50% Functions 1/2
30.76% Lines 4/13

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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 491x 4x   4x                                                                                     4x    
export default function handleDeprecatedOptions(opts) {
  const warnings = [];
 
  Iif (opts.customResolveOptions) {
    const { customResolveOptions } = opts;
    if (customResolveOptions.moduleDirectory) {
      // eslint-disable-next-line no-param-reassign
      opts.moduleDirectories = Array.isArray(
        customResolveOptions.moduleDirectory,
      )
        ? customResolveOptions.moduleDirectory
        : [customResolveOptions.moduleDirectory];
 
      warnings.push(
        "node-resolve: The `customResolveOptions.moduleDirectory` option has been deprecated. Use `moduleDirectories`, which must be an array.",
      );
    }
 
    if (customResolveOptions.preserveSymlinks) {
      throw new Error(
        "node-resolve: `customResolveOptions.preserveSymlinks` is no longer an option. We now always use the rollup `preserveSymlinks` option.",
      );
    }
 
    [
      "basedir",
      "package",
      "extensions",
      "includeCoreModules",
      "readFile",
      "isFile",
      "isDirectory",
      "realpath",
      "packageFilter",
      "pathFilter",
      "paths",
      "packageIterator",
    ].forEach((resolveOption) => {
      if (customResolveOptions[resolveOption]) {
        throw new Error(
          `node-resolve: \`customResolveOptions.${resolveOption}\` is no longer an option. If you need this, please open an issue.`,
        );
      }
    });
  }
 
  return { warnings };
}