-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
211 additions
and
115 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
|
||
function __spreadArrays() { | ||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; | ||
for (var r = Array(s), k = 0, i = 0; i < il; i++) | ||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) | ||
r[k] = a[j]; | ||
return r; | ||
} | ||
|
||
export { __spreadArrays }; |
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,10 @@ | ||
import { OSPathsAdaptionBuilder_ } from './lib/OSPaths.mjs'; | ||
import { adapter } from './platform-adapters/node.mjs'; | ||
|
||
var default_ = OSPathsAdaptionBuilder_(adapter); | ||
var haveModuleExports_ = typeof module === 'object' && module.exports; | ||
if (haveModuleExports_) { | ||
module.exports = default_; | ||
} | ||
|
||
export default default_; |
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,76 @@ | ||
import { __spreadArrays } from '../_virtual/_tslib.js'; | ||
|
||
function isEmpty(s) { | ||
return !s; | ||
} | ||
function OSPathsAdaptionBuilder_(adapter_) { | ||
var env = adapter_.env, os = adapter_.os, path = adapter_.path, process = adapter_.process; | ||
var isWinOS = /^win/i.test(process.platform); | ||
function normalizePath(path_) { | ||
return path_ ? path.normalize(path.join(path_, '.')) : void 0; | ||
} | ||
var posix = function () { | ||
var home = function () { | ||
return normalizePath((typeof os.homedir === 'function' ? os.homedir() : void 0) || env.get('HOME')); | ||
}; | ||
var temp = function () { | ||
var fallback = '/tmp'; | ||
var priorityList = [ | ||
typeof os.tmpdir === 'function' ? os.tmpdir() : void 0, | ||
env.get('TMPDIR'), | ||
env.get('TEMP'), | ||
env.get('TMP'), | ||
]; | ||
return normalizePath(priorityList.find(function (v) { return !isEmpty(v); })) || fallback; | ||
}; | ||
return { home: home, temp: temp }; | ||
}; | ||
var windows = function () { | ||
var home = function () { | ||
var priorityList = [ | ||
typeof os.homedir === 'function' ? os.homedir() : void 0, | ||
env.get('USERPROFILE'), | ||
env.get('HOME'), | ||
env.get('HOMEDRIVE') || env.get('HOMEPATH') | ||
? path.join(env.get('HOMEDRIVE') || '', env.get('HOMEPATH') || '') | ||
: void 0, | ||
]; | ||
return normalizePath(priorityList.find(function (v) { return !isEmpty(v); })); | ||
}; | ||
function joinPathToBase(base, segments) { | ||
return base ? path.join.apply(path, __spreadArrays([base], segments)) : void 0; | ||
} | ||
var temp = function () { | ||
var fallback = 'C:\\Temp'; | ||
var priorityListLazy = [ | ||
os.tmpdir, | ||
function () { return env.get('TEMP'); }, | ||
function () { return env.get('TMP'); }, | ||
function () { return joinPathToBase(env.get('LOCALAPPDATA'), ['Temp']); }, | ||
function () { return joinPathToBase(home(), ['AppData', 'Local', 'Temp']); }, | ||
function () { return joinPathToBase(env.get('ALLUSERSPROFILE'), ['Temp']); }, | ||
function () { return joinPathToBase(env.get('SystemRoot'), ['Temp']); }, | ||
function () { return joinPathToBase(env.get('windir'), ['Temp']); }, | ||
function () { return joinPathToBase(env.get('SystemDrive'), ['\\', 'Temp']); }, | ||
]; | ||
var v = priorityListLazy.find(function (v) { return v && !isEmpty(v()); }); | ||
return (v && normalizePath(v())) || fallback; | ||
}; | ||
return { home: home, temp: temp }; | ||
}; | ||
var OSPaths_ = (function () { | ||
function OSPaths_() { | ||
var OSPaths = function () { | ||
return new OSPaths_(); | ||
}; | ||
var platformOS = isWinOS ? windows() : posix(); | ||
OSPaths.home = platformOS.home; | ||
OSPaths.temp = platformOS.temp; | ||
return OSPaths; | ||
} | ||
return OSPaths_; | ||
}()); | ||
return new OSPaths_(); | ||
} | ||
|
||
export { OSPathsAdaptionBuilder_ }; |
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,15 @@ | ||
import * as os from 'os'; | ||
import * as path from 'path'; | ||
|
||
var adapter = { | ||
env: { | ||
get: function (s) { | ||
return process.env[s]; | ||
}, | ||
}, | ||
os: os, | ||
path: path, | ||
process: process, | ||
}; | ||
|
||
export { adapter }; |
Binary file not shown.
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,3 +1,2 @@ | ||
import { default as default_ } from './lib/OSPaths'; | ||
export * from './lib/OSPaths'; | ||
declare const default_: import("./lib/OSPaths").OSPaths; | ||
export default default_; |
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,8 +1,8 @@ | ||
import { Platform } from '../platform-adapters/_base'; | ||
export declare type OSPaths = { | ||
new (): OSPaths; | ||
(): OSPaths; | ||
readonly home: () => string | undefined; | ||
readonly temp: () => string; | ||
}; | ||
declare const default_: OSPaths; | ||
export default default_; | ||
export declare function OSPathsAdaptionBuilder_(adapter_: Platform.Adapter): OSPaths; |
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