File: cli.js

package info (click to toggle)
node-loose-envify 1.4.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 164 kB
  • sloc: makefile: 7
file content (46 lines) | stat: -rw-r--r-- 1,093 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'use strict';

var child_process = require('child_process');
var test = require('tap').test;

test('cli', function(t) {
  t.plan(5);

  var res = [];

  var ps = child_process.spawn(
    require.resolve('../cli.js'),
    [require.resolve('./react/react-with-addons-with-node_env.js')]
  );
  var out = '';
  var err = '';
  ps.stdout.on('data', function(buf) { out += buf; });
  ps.stderr.on('data', function(buf) { err += buf; });

  ps.on('close', function() {
    t.equal(err, '');
    t.ok(out);
    res.push(out);
    if (res.length === 2) done();
  });

  var envifyps = child_process.spawn(
    require.resolve('.bin/envify'),
    [require.resolve('./react/react-with-addons-with-node_env.js')]
  );
  var envifyout = '';
  var envifyerr = '';
  envifyps.stdout.on('data', function(buf) { envifyout += buf; });
  envifyps.stderr.on('data', function(buf) { envifyerr += buf; });

  envifyps.on('close', function() {
    t.equal(envifyerr, '');
    t.ok(envifyout);
    res.push(envifyout);
    if (res.length === 2) done();
  });

  function done() {
    t.same(res[0], res[1]);
  }
});