-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsecretsJson.ts
More file actions
25 lines (21 loc) · 759 Bytes
/
secretsJson.ts
File metadata and controls
25 lines (21 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import * as os from 'os';
import * as path from 'path';
import * as fse from 'fs-extra';
export function getSecretsPath(id: string) {
const platform = os.platform();
if (platform === 'win32') {
return path.join(os.homedir(), 'AppData', 'Roaming', 'Microsoft', 'UserSecrets', id, 'secrets.json');
} else if (platform === 'linux' || platform === 'darwin') {
return path.join(os.homedir(), '.microsoft', 'usersecrets', id, 'secrets.json');
} else {
return;
}
}
export async function ensureSecretsExist(secretsPath: string) {
if (!fse.existsSync(secretsPath)) {
await fse.outputFile(secretsPath, emptyJsonFileContent());
}
}
function emptyJsonFileContent() {
return `{${os.EOL} ${os.EOL}}`;
}