Skip to content

Replace isbinaryfile with istextorbinary#738

Merged
SBoudrias merged 1 commit intoyeoman:masterfrom
Toilal:feat/istextorbinary
Jan 18, 2015
Merged

Replace isbinaryfile with istextorbinary#738
SBoudrias merged 1 commit intoyeoman:masterfrom
Toilal:feat/istextorbinary

Conversation

@Toilal
Copy link
Contributor

@Toilal Toilal commented Jan 17, 2015

This avoid reading the file twice, and also drop one dependency when #737 is merged.

compared to isbinaryfile, istextorbinary can handles a Buffer as input instead of filename.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) when pulling faa963b on Toilal:feat/istextorbinary into 03c0ca3 on yeoman:master.

Copy link
Member

Choose a reason for hiding this comment

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

Let's not change value of a variable inside the if statement. It's making it harder to reason about.

isText = istextorbinary.isTextSync(undefined, body)

if (isText) {
  // foo
}

// etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well, it doesn't change any value, but i'll extract it np.

Copy link
Member

Choose a reason for hiding this comment

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

It changes var binary value. You should get rid of this variable.

It is easier to think about a thing that doesn't change than mutable variable values.

@Toilal Toilal force-pushed the feat/istextorbinary branch from faa963b to 541c3dc Compare January 17, 2015 21:32
@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) when pulling 541c3dc on Toilal:feat/istextorbinary into 45bb7a5 on yeoman:master.

@Toilal Toilal force-pushed the feat/istextorbinary branch from 541c3dc to bef92f8 Compare January 18, 2015 07:16
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not really part of this PR, but why this is not called for binary data ?

Copy link
Member

Choose a reason for hiding this comment

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

That's mostly legacy feature. You'll have the capacity to edit binary content using the new file system (package is mem-fs-editor).

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.0%) when pulling bef92f8 on Toilal:feat/istextorbinary into 45bb7a5 on yeoman:master.

SBoudrias added a commit that referenced this pull request Jan 18, 2015
Replace isbinaryfile with istextorbinary
@SBoudrias SBoudrias merged commit 697ecb2 into yeoman:master Jan 18, 2015
@SBoudrias
Copy link
Member

LGTM thanks for taking care of it!

@Toilal
Copy link
Contributor Author

Toilal commented Jan 18, 2015

A pleasure, great to have responsive people like your team in this project :)

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.

3 participants