You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test-config-cli.js 507 B

3 years ago
12345678910111213141516171819202122232425262728
  1. const cp = require('child_process')
  2. const path = require('path')
  3. const test = require('tap').test
  4. const nodeBinary = process.argv[0]
  5. test('config preload loads .env', t => {
  6. t.plan(1)
  7. const { stdout } = cp.spawnSync(
  8. nodeBinary,
  9. [
  10. '-r',
  11. '../config',
  12. '-e',
  13. 'console.log(process.env.BASIC)',
  14. 'dotenv_config_encoding=utf8'
  15. ],
  16. {
  17. cwd: path.resolve(__dirname),
  18. timeout: 5000,
  19. encoding: 'utf8'
  20. }
  21. )
  22. t.equal(stdout.trim(), 'basic')
  23. })