Home directory is process.env.USERPROFILE on Windows.

This commit is contained in:
Cheng Zhao 2013-10-21 22:04:51 +08:00
parent 640b6feb49
commit 0a561643a9
3 changed files with 10 additions and 5 deletions

View File

@ -134,6 +134,7 @@ describe "fs", ->
describe ".absolute(relativePath)", ->
it "converts a leading ~ segment to the HOME directory", ->
expect(fs.absolute('~')).toBe fs.realpathSync(process.env.HOME)
expect(fs.absolute(path.join('~', 'does', 'not', 'exist'))).toBe path.join(process.env.HOME, 'does', 'not', 'exist')
homeDir = atom.getHomeDirPath()
expect(fs.absolute('~')).toBe fs.realpathSync(homeDir)
expect(fs.absolute(path.join('~', 'does', 'not', 'exist'))).toBe path.join(homeDir, 'does', 'not', 'exist')
expect(fs.absolute('~test')).toBe '~test'

View File

@ -13,10 +13,12 @@ fsExtensions =
absolute: (relativePath) ->
return null unless relativePath?
homeDir = process.env[if process.platform is 'win32' then 'USERPROFILE' else 'HOME']
if relativePath is '~'
relativePath = process.env.HOME
relativePath = homeDir
else if relativePath.indexOf('~/') is 0
relativePath = "#{process.env.HOME}#{relativePath.substring(1)}"
relativePath = "#{homeDir}#{relativePath.substring(1)}"
try
fs.realpathSync(relativePath)

View File

@ -14,6 +14,8 @@ module.exports = (grunt) ->
rm 'atom-shell'
grunt.registerTask 'clean', 'Delete all the build files', ->
homeDir = process.env[if process.platform is 'win32' then 'USERPROFILE' else 'HOME']
rm 'node_modules'
rm path.join(process.env.HOME, '.atom', '.node-gyp')
rm path.join(homeDir, '.atom', '.node-gyp')
grunt.task.run('partial-clean')