Skip to content

Commit

Permalink
os: use const with early return for path
Browse files Browse the repository at this point in the history
PR-URL: #54959
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jake Yuesong Li <jake.yuesong@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
  • Loading branch information
trivikr committed Sep 18, 2024
1 parent 29f31c6 commit 87e7aeb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/os.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,13 @@ platform[SymbolToPrimitive] = () => process.platform;
*/
function tmpdir() {
if (isWindows) {
let path = process.env.TEMP ||
const path = process.env.TEMP ||
process.env.TMP ||
(process.env.SystemRoot || process.env.windir) + '\\temp';

if (path.length > 1 && StringPrototypeEndsWith(path, '\\') &&
!StringPrototypeEndsWith(path, ':\\'))
path = StringPrototypeSlice(path, 0, -1);
return StringPrototypeSlice(path, 0, -1);

return path;
}
Expand Down

0 comments on commit 87e7aeb

Please sign in to comment.