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

feat: add a sources option allowing to bypass fs operations #36

Merged
merged 1 commit into from
Jun 23, 2019
Merged

feat: add a sources option allowing to bypass fs operations #36

merged 1 commit into from
Jun 23, 2019

Conversation

SimenB
Copy link
Member

@SimenB SimenB commented Jun 23, 2019

This is a first, quick, pass for #33. It does not have docs or tests as I'd like to get some feedback on it if it's the correct approach, or if we should have different load methods depending on if we want to read from fs or not

Fixes #33

(includes #35)

@coveralls
Copy link

coveralls commented Jun 23, 2019

Pull Request Test Coverage Report for Build 136

  • 16 of 18 (88.89%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.2%) to 91.461%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/v8-to-istanbul.js 14 16 87.5%
Totals Coverage Status
Change from base Build 132: -0.2%
Covered Lines: 470
Relevant Lines: 511

💛 - Coveralls

Copy link
Member

@bcoe bcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, I'm ecstatic to have another party contributing to this codebase.

package.json Outdated Show resolved Hide resolved
index.d.ts Outdated Show resolved Hide resolved
Copy link
Member

@bcoe bcoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't complain if we add a test eventually 😄 but this looks reasonable to me.

@bcoe bcoe merged commit 4f5a681 into istanbuljs:master Jun 23, 2019
@SimenB SimenB deleted the pass-in-source-and-maps branch June 23, 2019 20:07
@SimenB
Copy link
Member Author

SimenB commented Jun 23, 2019

Definitely needs a test or two! I'll come back to it once we've settled on an API. This one feels a bit brute force.

I think maybe some of this sourcemap logic could move to istanbul-lib-source-maps? Maybe not

// both the transpiled and original source, both of which are used during
// the backflips we perform to remap absolute to relative positions.
const rawSourceMap = convertSourceMap.fromSource(rawSource) || convertSourceMap.fromMapFileSource(rawSource, dirname(this.path))
const rawSource = this.sources.source || readFileSync(this.path, 'utf8')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this.sources.source is a zero-length string, it still tries to read an actual file. I guess you meant

this.sources.source === undefined ? readFileSync(this.path, 'utf8') : this.sources.source

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call!

FWIW, I'm still not happy with the branching logic I introduced in this PR, I'd prefer an explicit .loadFromFs and .loadFromMemory or something API. Haven't had time to dig further into this yet though

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Separate APIs really sound good to me.

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

Successfully merging this pull request may close these issues.

Avoid hitting the file system
4 participants