| 1 |
"use strict"; |
| 2 |
var __importDefault = (this && this.__importDefault) || function (mod) { |
| 3 |
return (mod && mod.__esModule) ? mod : { "default": mod }; |
| 4 |
}; |
| 5 |
Object.defineProperty(exports, "__esModule", { value: true }); |
| 6 |
exports.appDataPath = appDataPath; |
| 7 |
/* |
| 8 |
Copyright 2023 The Sigstore Authors. |
| 9 |
|
| 10 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 11 |
you may not use this file except in compliance with the License. |
| 12 |
You may obtain a copy of the License at |
| 13 |
|
| 14 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 15 |
|
| 16 |
Unless required by applicable law or agreed to in writing, software |
| 17 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 18 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 |
See the License for the specific language governing permissions and |
| 20 |
limitations under the License. |
| 21 |
*/ |
| 22 |
const os_1 = __importDefault(require("os")); |
| 23 |
const path_1 = __importDefault(require("path")); |
| 24 |
function appDataPath(name) { |
| 25 |
const homedir = os_1.default.homedir(); |
| 26 |
switch (process.platform) { |
| 27 |
/* istanbul ignore next */ |
| 28 |
case 'darwin': { |
| 29 |
const appSupport = path_1.default.join(homedir, 'Library', 'Application Support'); |
| 30 |
return path_1.default.join(appSupport, name); |
| 31 |
} |
| 32 |
/* istanbul ignore next */ |
| 33 |
case 'win32': { |
| 34 |
const localAppData = process.env.LOCALAPPDATA || path_1.default.join(homedir, 'AppData', 'Local'); |
| 35 |
return path_1.default.join(localAppData, name, 'Data'); |
| 36 |
} |
| 37 |
/* istanbul ignore next */ |
| 38 |
default: { |
| 39 |
const localData = process.env.XDG_DATA_HOME || path_1.default.join(homedir, '.local', 'share'); |
| 40 |
return path_1.default.join(localData, name); |
| 41 |
} |
| 42 |
} |
| 43 |
} |