UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 823 B
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shouldFollow=shouldFollow;var fs=()=>{var tmp=require("fs");return fs=()=>tmp,tmp},path=()=>{var tmp=require("path");return path=()=>tmp,tmp},options_1=()=>{var tmp=require("./options");return options_1=()=>tmp,tmp};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))}}