-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: always get the executor's homedir (#17)
- Loading branch information
Showing
3 changed files
with
16 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,31 @@ | ||
'use strict'; | ||
|
||
const mm = require('mm'); | ||
const os = require('os'); | ||
const utils = require('../../lib/utils'); | ||
const should = require('should'); | ||
|
||
describe('test/utils/index.test.js', () => { | ||
|
||
afterEach(mm.restore); | ||
|
||
describe('utils.getHomedir()', () => { | ||
it('should return process.env.HOME', () => { | ||
if (os.userInfo && os.userInfo().homedir) { | ||
const userInfo = os.userInfo(); | ||
delete userInfo.homedir; | ||
mm(os, 'userInfo', () => userInfo); | ||
} | ||
utils.getHomedir().should.equal(process.env.HOME); | ||
}); | ||
|
||
it('should return /home/admin when process.env.HOME is not exist', () => { | ||
mm(process.env, 'HOME', ''); | ||
utils.getHomedir().should.equal('/home/admin'); | ||
if (os.userInfo && os.userInfo().homedir) { | ||
should.ok(utils.getHomedir().indexOf(process.env.USER) > -1); | ||
} else { | ||
utils.getHomedir().should.equal('/home/admin'); | ||
} | ||
}); | ||
}); | ||
}); |