@@ -8,6 +8,8 @@ const fixtures = require('../common/fixtures');
|
8 | 8 | |
9 | 9 | const validEnvFilePath = '../fixtures/dotenv/valid.env'; |
10 | 10 | const nodeOptionsEnvFilePath = '../fixtures/dotenv/node-options.env'; |
| 11 | +const noFinalNewlineEnvFilePath = '../fixtures/dotenv/no-final-newline.env'; |
| 12 | +const noFinalNewlineSingleQuotesEnvFilePath = '../fixtures/dotenv/no-final-newline-single-quotes.env'; |
11 | 13 | |
12 | 14 | describe('.env supports edge cases', () => { |
13 | 15 | it('supports multiple declarations, including optional ones', async () => { |
@@ -148,4 +150,24 @@ describe('.env supports edge cases', () => {
|
148 | 150 | assert.strictEqual(child.stderr, ''); |
149 | 151 | assert.strictEqual(child.code, 0); |
150 | 152 | }); |
| 153 | + |
| 154 | +it('should handle file without a final newline', async () => { |
| 155 | +const code = ` |
| 156 | + require('assert').strictEqual(process.env.BASIC, 'basic'); |
| 157 | + `.trim(); |
| 158 | +const child = await common.spawnPromisified( |
| 159 | +process.execPath, |
| 160 | +[ `--env-file=${path.resolve(__dirname, noFinalNewlineEnvFilePath)}`, '--eval', code ], |
| 161 | +); |
| 162 | + |
| 163 | +const SingleQuotesChild = await common.spawnPromisified( |
| 164 | +process.execPath, |
| 165 | +[ `--env-file=${path.resolve(__dirname, noFinalNewlineSingleQuotesEnvFilePath)}`, '--eval', code ], |
| 166 | +); |
| 167 | + |
| 168 | +assert.strictEqual(child.stderr, ''); |
| 169 | +assert.strictEqual(child.code, 0); |
| 170 | +assert.strictEqual(SingleQuotesChild.stderr, ''); |
| 171 | +assert.strictEqual(SingleQuotesChild.code, 0); |
| 172 | +}); |
151 | 173 | }); |