UNPKG

aws-sdk-js-codemod

Version:

Collection of codemod scripts that help update AWS SDK for JavaScript APIs

17 lines (16 loc) 822 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFormattedSourceString = void 0; /** * Returns formatted source string for changes which can't be applied automatically. */ const getFormattedSourceString = (source) => source // Remove newlines from ObjectPattern require declarations. .replace(/\{\n {2}([\w,\n ]+)\n\} = require\((['"])@aws-sdk/g, (_, identifiers, quote) => `{ ${identifiers .split(",") .map((str) => str.trimLeft()) .filter((str) => str !== "") .join(", ")} } = require(${quote}@aws-sdk`) // Remove extra newlines between require declarations. .replace(/@aws-sdk\/([\w-]+)(['"])\);\n\nconst \{/g, (_, packageName, quote) => `@aws-sdk/${packageName}${quote});\nconst {`); exports.getFormattedSourceString = getFormattedSourceString;