flow-upgrade 2.40.0 → 2.41.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/dist/runCodemods.js +23 -21
- package/package.json +1 -1
package/dist/runCodemods.js
CHANGED
|
@@ -7,27 +7,29 @@ exports.default = runCodemods;
|
|
|
7
7
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
async function runCodemods(codemods, filePaths, options) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
for (const filePath of filePaths) {
|
|
11
|
+
try {
|
|
12
|
+
if (typeof require !== 'undefined' && require.cache) {
|
|
13
|
+
Object.keys(require.cache).forEach(key => {
|
|
14
|
+
if (key.includes('hermes-transform') || key.includes('prettier')) {
|
|
15
|
+
delete require.cache[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const originalContents = await _fsExtra.default.readFile(filePath, 'utf8');
|
|
20
|
+
let contents = originalContents;
|
|
21
|
+
for (const codemod of codemods) {
|
|
22
|
+
if (typeof jest !== 'undefined') {
|
|
23
|
+
jest.resetModules();
|
|
15
24
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
25
|
+
const {
|
|
26
|
+
transform
|
|
27
|
+
} = require('hermes-transform');
|
|
28
|
+
contents = await transform(contents, codemod.transform, options.prettierOptions);
|
|
29
|
+
}
|
|
30
|
+
if (originalContents !== contents) {
|
|
31
|
+
await _fsExtra.default.writeFile(filePath, contents, 'utf8');
|
|
23
32
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
} = require('hermes-transform');
|
|
27
|
-
contents = await transform(contents, codemod.transform, options.prettierOptions);
|
|
28
|
-
}
|
|
29
|
-
if (originalContents !== contents) {
|
|
30
|
-
await _fsExtra.default.writeFile(filePath, contents, 'utf8');
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
33
|
+
} catch (error) {}
|
|
34
|
+
}
|
|
33
35
|
}
|