Skip to content

Commit

Permalink
Amend: Use stub resolver for re-sourcing stream
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkemperman committed Nov 10, 2017
1 parent 19b8c87 commit fdf81fc
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/dest/write-contents/write-stream.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
'use strict';

var iconv = require('iconv-lite');
var createResolver = require('resolve-options');

var fo = require('../../file-operations');
var getCodec = require('../../codecs');
var readStream = require('../../src/read-contents/read-stream');
var readConfig = require('../../src/options');

function writeStream(file, optResolver, onWritten) {
var encoding = optResolver.resolve('encoding', file);
Expand Down Expand Up @@ -60,10 +58,17 @@ function writeStream(file, optResolver, onWritten) {
file.contents.removeListener('error', onComplete);

// TODO: this is doing sync stuff & the callback seems unnecessary
readStream(file, createResolver(readConfig, {
encoding: encoding,
removeBOM: false,
}), complete);
readStream(file, { resolve: resolve }, complete);

function resolve(key) {
if (key === 'encoding') {
return encoding;
}
if (key === 'removeBOM') {
return false;
}
throw new Error('Eek! stub resolver doesn\'t have ' + key);
}

function complete() {
if (typeof fd !== 'number') {
Expand Down

0 comments on commit fdf81fc

Please sign in to comment.