0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
nodejs/test/parallel/test-os-homedir-no-envvar.js
cjihrig 6e78e5feaa os: add homedir()
os.homedir() calls libuv's uv_os_homedir() to retrieve the current
user's home directory.

PR-URL: https://github.com/nodejs/io.js/pull/1791
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
2015-06-05 22:58:14 -04:00

31 lines
688 B
JavaScript

'use strict';
var common = require('../common');
var assert = require('assert');
var cp = require('child_process');
var os = require('os');
var path = require('path');
if (process.argv[2] === 'child') {
if (common.isWindows)
assert.equal(process.env.USERPROFILE, undefined);
else
assert.equal(process.env.HOME, undefined);
var home = os.homedir();
assert.ok(typeof home === 'string');
assert.ok(home.indexOf(path.sep) !== -1);
} else {
if (common.isWindows)
delete process.env.USERPROFILE;
else
delete process.env.HOME;
var child = cp.spawnSync(process.execPath, [__filename, 'child'], {
env: process.env
});
assert.equal(child.status, 0);
}