UNPKG

743 BJavaScriptView Raw
1/*
2 * MIT License http://opensource.org/licenses/MIT
3 * Author: Ben Holloway @bholloway
4 */
5'use strict';
6
7var stream = require('stream');
8
9var maybeStream = process[process.env.RESOLVE_URL_LOADER_TEST_HARNESS];
10
11function logToTestHarness(options) {
12 if (!!maybeStream && (typeof maybeStream === 'object') && (maybeStream instanceof stream.Writable)) {
13 Object.keys(options).map(eachOptionKey);
14 maybeStream = null; // ensure we log only once
15 }
16
17 function eachOptionKey(key) {
18 var value = options[key];
19 var text = (typeof value === 'undefined') ?
20 String(value) :
21 (JSON.stringify(value.valueOf()) || '-unstringifyable-');
22 maybeStream.write(key + ': ' + text + '\n');
23 }
24}
25
26module.exports = logToTestHarness;