question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple transform support

See original GitHub issue

I’ve got a collection of transforms that don’t really make sense to be run individually. I’d like to provide a straightforward way to run them all against a group of files. I don’t see a way to do this with jscodeshift currently, but it seems useful.

ava-codemods does this by running jscodeshift once per transform. It’s a bit brute-force, but it’ll work for now until (if?) jscodeshift adds support.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:7
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
stevecooperorgcommented, Feb 23, 2017

A cheap and cheerful approach is to create a ‘master’ transform which uses the output of one transform as the input to the next. This is working fairly well for me; wouldn’t call it production code but for the hacking I’ve been doing it suffices. Might be useful to someone else;

import fix1 from './fix1'
import fix2 from './fix2'
import fix3 from './fix3'

module.exports = function(file, api, options) {
    const fixes = [fix1,fix2,fix3];
    let src = file.source;
    fixes.forEach(fix => {
        if (typeof(src) === "undefined") { return; }
        src = fix({ ...file, source:src }, api, options);
    });
    return src;
};

4reactions
fklingcommented, Sep 14, 2016

That seems very reasonable to me. As a first step, we can pass multiple transforms to the workers and have them apply each one in series (will have to check how custom parser selections impacts this, but I think it should work without problem).

Later we could avoid code generation from the AST and provide a way to “chain” transforms and reuse the existing AST. That would require some thought around custom parsers though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to apply multiple transforms in CSS? - Stack Overflow
Keep in mind multiple transform one line directives are applied from right to left. This: transform: scale(1,1.5) rotate(90deg); and: transform: ...
Read more >
transform - CSS: Cascading Style Sheets - MDN Web Docs
The transform CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual ...
Read more >
CSS Tutorial => Multiple transforms
Multiple transforms can be applied to an element in one property like this: transform: rotate(15deg) translateX(200px);. This will rotate the element 15 degrees ......
Read more >
How to Apply Multiple Transforms in CSS - W3docs
There are many ways to apply multiple transforms. We'll show how to achieve this using multiple values of the transform property and with...
Read more >
Using Multiple Transform Files in PDQ Deploy - Support
Purpose: You wish to deploy a software package with multiple transform (MST) files. Resolution: Use the TRANSFORMS property in Install...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found