summaryrefslogtreecommitdiff
path: root/node_modules/write-file-stdout/index.js
blob: 10d804ec34dd746cf4ebaf654153a8807c180dcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var fs = require('fs');

/**
 * Expose `write`.
 */

module.exports = write;

/**
 * Write `contents` to a `file`, falling back to stdout.
 *
 * @param {String} file
 * @param {String} contents
 */

function write (file, contents) {
  if (1 == arguments.length) contents = file, file = null;
  if (file) return fs.writeFileSync(file, contents);
  process.stdout.write(contents);
}