From 667bd049f237c34df1b343a84d43bb0dc6146fbb Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 13 Feb 2018 03:01:46 +0100 Subject: [PATCH 1/2] tools: enable no-unsafe-finally This enables the `no-unsafe-finally` eslint rule to make sure we have a proper control flow in try / catch. --- .eslintrc.yaml | 1 + test/common/index.js | 12 ++++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 0839e352cd399d..e73e97dede44af 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -152,6 +152,7 @@ rules: }] no-tabs: error no-trailing-spaces: error + no-unsafe-finally: error object-curly-spacing: [error, always] one-var-declaration-per-line: error operator-linebreak: [error, after] diff --git a/test/common/index.js b/test/common/index.js index e8546db3a2f4ea..99ca672b0f3b6b 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -504,17 +504,13 @@ exports.canCreateSymLink = function() { const whoamiPath = path.join(process.env['SystemRoot'], 'System32', 'whoami.exe'); - let err = false; - let output = ''; - try { - output = execSync(`${whoamiPath} /priv`, { timout: 1000 }); - } catch (e) { - err = true; - } finally { - if (err || !output.includes('SeCreateSymbolicLinkPrivilege')) { + const output = execSync(`${whoamiPath} /priv`, { timout: 1000 }); + if (!output.includes('SeCreateSymbolicLinkPrivilege')) { return false; } + } catch (e) { + return false; } } From 485b3cb97bde23de045b1597152f4f7a48752496 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 13 Feb 2018 12:45:41 +0100 Subject: [PATCH 2/2] fixup: address comment --- test/common/index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/test/common/index.js b/test/common/index.js index 99ca672b0f3b6b..8ffeda42dfd52c 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -506,15 +506,11 @@ exports.canCreateSymLink = function() { try { const output = execSync(`${whoamiPath} /priv`, { timout: 1000 }); - if (!output.includes('SeCreateSymbolicLinkPrivilege')) { - return false; - } + return output.includes('SeCreateSymbolicLinkPrivilege'); } catch (e) { return false; } } - - return true; }; exports.getCallSite = function getCallSite(top) {