aws-cdk-lib
Version:
Version 2 of the AWS Cloud Development Kit library
2 lines (1 loc) • 718 B
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0}),exports.shouldFollow=void 0;const fs=require("fs"),path=require("path"),options_1=require("./options");function shouldFollow(mode,sourceRoot,realPath){switch(mode){case options_1.SymlinkFollowMode.ALWAYS:return fs.existsSync(realPath);case options_1.SymlinkFollowMode.EXTERNAL:return!_isInternal()&&fs.existsSync(realPath);case options_1.SymlinkFollowMode.BLOCK_EXTERNAL:return _isInternal()&&fs.existsSync(realPath);case options_1.SymlinkFollowMode.NEVER:return!1;default:throw new Error(`Unsupported FollowMode: ${mode}`)}function _isInternal(){return path.resolve(realPath).startsWith(path.resolve(sourceRoot))}}exports.shouldFollow=shouldFollow;