From 12896dfb0f4c3c1a4c5d7186e5f2b6dace62da03 Mon Sep 17 00:00:00 2001 From: Bryan Clark Date: Thu, 5 Dec 2019 00:41:50 -0500 Subject: [PATCH] logging options --- dist/index.js | 8 ++++---- src/auth.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/index.js b/dist/index.js index 32058f3..22c99c9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4165,17 +4165,17 @@ function write(directory, settings) { return __awaiter(this, void 0, void 0, function* () { const options = { encoding: 'utf-8', flag: 'wx' }; // 'wx': Like 'w' but fails if path exists const location = path.join(directory, exports.SETTINGS_FILE); - console.log(`writing ${location}`); + console.log(`writing ${location} with options ${options}`); try { - return fs.writeFileSync(location, settings, options); + fs.writeFileSync(location, settings, options); } catch (e) { - if (!e.code) - throw e; if (e.code == fs.constants.O_EXCL) { console.log(`overwriting existing file ${location}`); + // default flag is 'w' return fs.writeFileSync(location, settings, { encoding: 'utf-8' }); } + throw e; } }); } diff --git a/src/auth.ts b/src/auth.ts index 875c6b4..2e83ede 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -46,9 +46,9 @@ export function generate(id: string, username: string, password: string) { async function write(directory: string, settings: string) { const options = {encoding: 'utf-8', flag: 'wx'}; // 'wx': Like 'w' but fails if path exists const location = path.join(directory, SETTINGS_FILE); - console.log(`writing ${location}`); + console.log(`writing ${location} with options ${options}`); try { - return fs.writeFileSync(location, settings, options); + fs.writeFileSync(location, settings, options); } catch (e) { if (e.code == fs.constants.O_EXCL) { console.log(`overwriting existing file ${location}`);