Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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.
  • Loading branch information
BridgeAR committed Feb 13, 2018
commit 667bd049f237c34df1b343a84d43bb0dc6146fbb
1 change: 1 addition & 0 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
12 changes: 4 additions & 8 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be simplified to just this, I think?

return output.includes('SeCreateSymbolicLinkPrivilege');

And then you don't need the return true a few lines below.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yepp, absolutely

} catch (e) {
return false;
}
}

Expand Down