UNPKG

923 BJavaScriptView Raw
1'use strict'
2
3const test = require('tap').test
4const path = require('path')
5const async = require('async')
6const { spawn } = require('child_process')
7const endpoint = require('endpoint')
8
9test('cmd - collect - NODE_OPTIONS environment is not ignored', function (t) {
10 const child = spawn(
11 process.execPath, [
12 path.resolve(__dirname, 'cmd-collect-node-options-env.script.js')
13 ], {
14 env: Object.assign({}, process.env, {
15 NODE_OPTIONS: '--no-warnings --stack-trace-limit=4013'
16 }),
17 cwd: __dirname
18 }
19 )
20
21 async.parallel({
22 stdout (done) { child.stdout.pipe(endpoint(done)) },
23 stderr (done) { child.stderr.pipe(endpoint(done)) }
24 }, function (err, output) {
25 if (err) return t.ifError(err)
26
27 // Expect the WARNING output to be shown
28 t.ok(output.stderr.toString().split('\n').length, 1)
29 t.strictEqual(output.stdout.toString().trim(), '4013')
30 t.end()
31 })
32})