MCPcopy Index your code
hub / github.com/nodejs/node / canCreateSymLink

Function canCreateSymLink

test/common/index.js:539–560  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

537}
538
539function canCreateSymLink() {
540 // On Windows, creating symlinks requires admin privileges.
541 // We'll only try to run symlink test if we have enough privileges.
542 // On other platforms, creating symlinks shouldn't need admin privileges
543 if (isWindows) {
544 // whoami.exe needs to be the one from System32
545 // If unix tools are in the path, they can shadow the one we want,
546 // so use the full path while executing whoami
547 const whoamiPath = path.join(process.env.SystemRoot,
548 'System32', 'whoami.exe');
549
550 try {
551 const { execSync } = require('child_process');
552 const output = execSync(`${whoamiPath} /priv`, { timeout: 1000 });
553 return output.includes('SeCreateSymbolicLinkPrivilege');
554 } catch {
555 return false;
556 }
557 }
558 // On non-Windows platforms, this always returns `true`
559 return true;
560}
561
562function mustNotCall(msg) {
563 const callSite = getCallSites()[1];

Calls 4

execSyncFunction · 0.85
includesMethod · 0.80
requireFunction · 0.50
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…