-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransform.ts
More file actions
41 lines (33 loc) · 1009 Bytes
/
transform.ts
File metadata and controls
41 lines (33 loc) · 1009 Bytes
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
import type { API, FileInfo, Options } from 'jscodeshift';
export default function transform(
fileInfo: FileInfo,
api: API,
options: Options,
) {
const j = api.jscodeshift;
const { updatedConfig } = options;
// console.log('OSTRA', updatedConfig);
// return fileInfo.source;
const root = j(fileInfo.source);
// const a = root.find(j.Program).get('body', 0);
// const a = root.find(j.Program).get('body', 0);
// console.log(a.value.declaration.properties[0]);
root.find(j.Property).forEach((path) => {
if (
updatedConfig.outDir &&
path.getValueProperty('key').name === 'outDir'
) {
// path.setValueProperty('value', updatedConfig.outDir);
path.value.value.value = updatedConfig.outDir;
}
});
// root.find(j.Identifier).forEach((path) => {
// if (path.value.name === 'outDir') {
// console.log(path.value);
// }
// });
// a.find(j).forEach((path) => {
// console.log(path.value);
// });
return root.toSource();
}