-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request atom#13965 from kinvolk/krnowak/custom-install-dir
Allow specifying installation directory
- Loading branch information
Showing
7 changed files
with
41 additions
and
12 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict' | ||
|
||
const os = require('os') | ||
const passwdUser = require('passwd-user') | ||
const path = require('path') | ||
|
||
module.exports = function (aPath) { | ||
if (!aPath.startsWith('~')) { | ||
return aPath | ||
} | ||
|
||
const sepIndex = aPath.indexOf(path.sep) | ||
const user = (sepIndex < 0) ? aPath.substring(1) : aPath.substring(1, sepIndex) | ||
const rest = (sepIndex < 0) ? '' : aPath.substring(sepIndex) | ||
const home = (user === '') ? os.homedir() : (() => { | ||
const passwd = passwdUser.sync(user); | ||
if (passwd === undefined) { | ||
throw new Error(`Failed to expand the tilde in ${aPath} - user "${user}" does not exist`) | ||
} | ||
return passwd.homedir | ||
})() | ||
|
||
return `${home}${rest}` | ||
} |
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