@mui/codemod 5.4.4 → 5.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/codemod.js CHANGED
File without changes
@@ -7,21 +7,26 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = transformer;
9
9
 
10
+ var _path = require("path");
11
+
10
12
  var _jscodeshiftAddImports = _interopRequireDefault(require("jscodeshift-add-imports"));
11
13
 
14
+ var _getJSExports = _interopRequireDefault(require("../util/getJSExports"));
15
+
16
+ // istanbul ignore next
17
+ if (process.env.NODE_ENV === 'test') {
18
+ const resolve = require.resolve;
19
+
20
+ require.resolve = source => resolve(source.replace(/^@mui\/material\/modern/, '../../../mui-material/src'));
21
+ }
22
+
12
23
  function transformer(fileInfo, api, options) {
13
24
  const j = api.jscodeshift;
14
25
  const importModule = options.importModule || '@mui/material';
15
26
  const targetModule = options.targetModule || '@mui/material';
16
- let requirePath = importModule;
17
-
18
- if (process.env.NODE_ENV === 'test') {
19
- requirePath = requirePath.replace(/^@mui\/material/, '../../../mui-material/src');
20
- } // eslint-disable-next-line global-require, import/no-dynamic-require
21
-
22
-
23
- const whitelist = require(requirePath);
24
-
27
+ const whitelist = (0, _getJSExports.default)(require.resolve(`${importModule}/modern`, {
28
+ paths: [(0, _path.dirname)(fileInfo.path)]
29
+ }));
25
30
  const printOptions = options.printOptions || {
26
31
  quote: 'single',
27
32
  trailingComma: true
@@ -64,7 +69,7 @@ function transformer(fileInfo, api, options) {
64
69
  const localName = specifier.local.name;
65
70
  const moduleName = match[1];
66
71
 
67
- if (whitelist[moduleName] == null) {
72
+ if (!whitelist.has(moduleName)) {
68
73
  return;
69
74
  }
70
75
 
@@ -74,7 +79,7 @@ function transformer(fileInfo, api, options) {
74
79
  }
75
80
 
76
81
  case 'ImportSpecifier':
77
- if (whitelist[specifier.imported.name] == null && specifier.imported.name !== 'withStyles') {
82
+ if (!whitelist.has(specifier.imported.name) == null && specifier.imported.name !== 'withStyles') {
78
83
  return;
79
84
  }
80
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/codemod",
3
- "version": "5.4.4",
3
+ "version": "5.5.0",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",