Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable 2-way sync #40

Open
kevinswiber opened this issue Sep 4, 2020 · 1 comment
Open

Enable 2-way sync #40

kevinswiber opened this issue Sep 4, 2020 · 1 comment

Comments

@kevinswiber
Copy link
Contributor

It would be nice if we could make changes in the Postman app and have them sync with the postman-cli'd bootstrapped version. Right now, I think improvements introduced by a solution to #12 could help facilitate that. Three-way merge on conflict is a related big deal, so I'll defer.

Otherwise, we can potentially detect if the Postman-hosted script has been browserify'd and extract the source using a JavaScript parser.

A quick and dirty test seems to show it could work:

const fs = require('fs');
const acorn = require('acorn');

const source = fs.readFileSync('./subject.js').toString('utf8');
const result = acorn.parse(source, { ecmaVersion: 2020 });
const bundledSources = result.body[0].expression.arguments[0].properties;
const scriptSource = bundledSources[bundledSources.length - 1];
const bodyElements = scriptSource.value.elements[0].body.body;

const start = bodyElements[0].start;
const end = bodyElements[bodyElements.length - 1].end;

const body = source.substring(start, end);
console.log(body);

Just not sure if we'd want it to work. 😅

Ian Malcolm

@matt-ball
Copy link
Owner

I agree with your last point - I am conflicted on this. What I would love is to be able to somehow abstract everything browserify does, but I am not sure how.

To me this also plays into trying to remove sync altogether - having some kind of autosync on save or something like hot reloading for Postman.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants