Skip to content

Commit

Permalink
Merge pull request #738 from Toilal/feat/istextorbinary
Browse files Browse the repository at this point in the history
Replace isbinaryfile with istextorbinary
  • Loading branch information
SBoudrias committed Jan 18, 2015
2 parents 45bb7a5 + bef92f8 commit 697ecb2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions lib/actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var fs = require('fs');
var path = require('path');
var mkdirp = require('mkdirp');
var isBinaryFile = require('isbinaryfile');
var istextorbinary = require('istextorbinary');
var chalk = require('chalk');
var xdgBasedir = require('xdg-basedir');
var engine = require('../util/engines').underscore;
Expand All @@ -23,7 +23,6 @@ actions.cacheRoot = function cacheRoot() {

// Copy helper for two versions of copy action
actions._prepCopy = function _prepCopy(source, destination, process) {
var body;
destination = destination || source;

if (typeof destination === 'function') {
Expand All @@ -35,17 +34,18 @@ actions._prepCopy = function _prepCopy(source, destination, process) {
destination = this.isPathAbsolute(destination) ? destination : path.join(this.destinationRoot(), destination);

var encoding = null;
var binary = isBinaryFile(source);
if (!binary) {
encoding = 'utf8';
}
var body = fs.readFileSync(source);

var isText = istextorbinary.isTextSync(undefined, body);

body = fs.readFileSync(source, encoding);
if (isText) {
body = body.toString();

if (typeof process === 'function' && !binary) {
body = process(body, source, destination, {
encoding: encoding
});
if (typeof process === 'function') {
body = process(body, source, destination, {
encoding: encoding
});
}
}

return {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"glob": "^4.3.2",
"gruntfile-editor": "^0.2.0",
"inquirer": "^0.8.0",
"isbinaryfile": "^2.0.0",
"istextorbinary": "^1.0.2",
"lodash": "^2.4.1",
"mem-fs-editor": "^1.0.0",
"mime": "^1.2.9",
Expand Down

0 comments on commit 697ecb2

Please sign in to comment.