Skip to content

Commit

Permalink
Update transform_files.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaMan123 committed Oct 31, 2022
1 parent 2d1d1da commit b8de8aa
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions scripts/transform_files.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -323,18 +323,20 @@ function transformClass(type, raw, options = {}) {
node.callee.property?.name === 'callSuper'
) {
const [methodNameArg, ...args] = node.arguments;
const lastArg = args[args.length - 1];
const removeParen =
lastArg?.type === 'Identifier' || lastArg?.type === 'Literal';
const out = `${
methodNameArg.value === 'initialize'
? 'super'
: `super.${methodNameArg.value}`
}(${printASTNode(value, args)})`;
console.log(printNode(node));
superTransforms.push({
node,
methodName: methodNameArg.value,
value: out,
value:
out.split('(').length < out.split(')').length &&
out[out.length - 1] === ')'
? out.slice(0, -1)
: out,
});
}
},
Expand Down Expand Up @@ -484,7 +486,6 @@ function convertFile(type, source, dest, options) {
});
dest = (typeof dest === 'function' ? dest(name) : dest) || source;
fs.writeFileSync(dest, raw);
cp.execSync(`prettier --write ${source}`);
options.verbose &&
console.log({
state: 'success',
Expand Down Expand Up @@ -602,6 +603,12 @@ export function transform(options = {}) {
);
});

cp.execSync(
`prettier --write ${result
.map(({ dir, file }) => path.relative('.', path.resolve(dir, file)))
.join(' ')}`
);

const [errors, files] = _.partition(result, (file) => file instanceof Error);
const dirs = files.reduce((dirs, { dir, file }) => {
(dirs[dir] || (dirs[dir] = [])).push(file);
Expand Down

0 comments on commit b8de8aa

Please sign in to comment.