• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var test = require('tap').test;
2var promzard = require('../');
3
4if (process.argv[2] === 'child') {
5  return child()
6}
7
8test('exports', function (t) {
9  t.plan(1);
10
11  var spawn = require('child_process').spawn
12  var child = spawn(process.execPath, [__filename, 'child'])
13
14  var output = ''
15  child.stderr.on('data', function (c) {
16    output += c
17  })
18
19  setTimeout(function () {
20    child.stdin.write('\n');
21  }, 100)
22  setTimeout(function () {
23    child.stdin.end('55\n');
24  }, 200)
25
26  child.on('close', function () {
27    console.error('output=%j', output)
28    output = JSON.parse(output)
29    t.same({
30      a : 3,
31      b : '!2b',
32      c : {
33        x : 55,
34        y : '/tmp/y/file.txt',
35      }
36    }, output);
37    t.end()
38  })
39});
40
41function child () {
42  var ctx = { tmpdir : '/tmp' }
43  var file = __dirname + '/exports.input';
44
45  promzard(file, ctx, function (err, output) {
46    console.error(JSON.stringify(output))
47  });
48}
49