File: test.js

package info (click to toggle)
node-os-tmpdir 1.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 112 kB
  • ctags: 4
  • sloc: makefile: 2; sh: 2
file content (42 lines) | stat: -rw-r--r-- 1,187 bytes parent folder | download
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
import test from 'ava';
import m from './';

const os = {tmpdir: m};

test(t => {
	// https://github.com/nodejs/node/blob/3e7a14381497a3b73dda68d05b5130563cdab420/test/parallel/test-os.js#L6-L38
	process.env.TMPDIR = '/tmpdir';
	process.env.TMP = '/tmp';
	process.env.TEMP = '/temp';

	if (process.platform === 'win32') {
		t.is(os.tmpdir(), '/temp');
		process.env.TEMP = '';
		t.is(os.tmpdir(), '/tmp');
		process.env.TMP = '';
		const expected = (process.env.SystemRoot || process.env.windir) + '\\temp';
		t.is(os.tmpdir(), expected);
		process.env.TEMP = '\\temp\\';
		t.is(os.tmpdir(), '\\temp');
		process.env.TEMP = '\\tmpdir/';
		t.is(os.tmpdir(), '\\tmpdir/');
		process.env.TEMP = '\\';
		t.is(os.tmpdir(), '\\');
		process.env.TEMP = 'C:\\';
		t.is(os.tmpdir(), 'C:\\');
	} else {
		t.is(os.tmpdir(), '/tmpdir');
		process.env.TMPDIR = '';
		t.is(os.tmpdir(), '/tmp');
		process.env.TMP = '';
		t.is(os.tmpdir(), '/temp');
		process.env.TEMP = '';
		t.is(os.tmpdir(), '/tmp');
		process.env.TMPDIR = '/tmpdir/';
		t.is(os.tmpdir(), '/tmpdir');
		process.env.TMPDIR = '/tmpdir\\';
		t.is(os.tmpdir(), '/tmpdir\\');
		process.env.TMPDIR = '/';
		t.is(os.tmpdir(), '/');
	}
});