获得 mock server 的构建之后的根目录绝对路径
@param {String} rootPath 项目根目录
@param {String} buildPath
@returns {String}
495504
function getBuildPath(rootPath, buildPath) {
    let result = buildPath || './build';

    if (!path.isAbsolute(result)) {
        result = path.resolve(rootPath, result);
    }

    return result;
}
1364681
private Path<?> buildPropertyPathForAnyType(Root<T> root, String stringPath) {
		
		// Si la racine est nulle
		if(root == null) return null;
		
		// Si la chaine est vide
		if(stringPath == null || stringPath.trim().length() == 0) return null;
		
		// Le Path à retournet
		Path<?> path = null;
		
		// On splitte sur le séparateur de champs
		String[] hierarchicalPaths = stringPath.trim().split("\\.");
		
		// Obtention du premier chemin
		path = root.get(hierarchicalPaths[0]);
		
		// Si la taille est > 1
		if(hierarchicalPaths.length > 1) {

			// Parcours
			for (int i = 1; i < hierarchicalPaths.length; i++) {
				
				// Le chemin
				String unitPath = hierarchicalPaths[i];
				
				// Si le path est vide ou est une suite d'espace
				if(unitPath == null || unitPath.trim().length() == 0) continue;
				
				// Acces à la ppt
				path = path.get(unitPath.trim());
			}
		}
		
		// On retourne le Path
		return path;
	}
421275
public static String buildProperPath(String parentPath, String relativePathFromParent) {
        if (relativePathFromParent == null) return null;
        if (parentPath != null) {
            parentPath = parentPath.trim();
        }

        if (relativePathFromParent.startsWith(PATH_CURRENT)) {
            relativePathFromParent = relativePathFromParent.replaceFirst("(./)+", "");
        }

        String path;

        if (relativePathFromParent.startsWith(PATH_ROOT)) { //absolute
            path = relativePathFromParent;
        } else if (relativePathFromParent.startsWith(PATH_PARENT)) {
            while (relativePathFromParent.startsWith(PATH_PARENT)) {
                relativePathFromParent = relativePathFromParent.replaceFirst(PATH_PARENT, "");
                if (relativePathFromParent.startsWith(PATH_CURRENT)) {
                    relativePathFromParent = relativePathFromParent.replaceFirst(PATH_CURRENT, "");
                }
                parentPath = (parentPath == null || parentPath.equals(PATH_ROOT)) ? PATH_ROOT : getParentPath(parentPath);
            }
            path = parentPath + PATH_ROOT + relativePathFromParent;
        } else {
            path = parentPath + PATH_ROOT + relativePathFromParent;
        }

        return path.replaceAll("(/|\\./)+", "$1");
    }
116268
private String getShortPath(String rootPath) {
        File file = new File(rootPath);
        String lastPathAfterSeparator = null;
        String shortPath = getWindowsShortPath(file.getAbsolutePath());
        if (StringUtils.isNotEmpty(shortPath)) {
            return getWindowsShortPath(file.getAbsolutePath());
        } else {
            while (StringUtils.isEmpty(getWindowsShortPath(file.getAbsolutePath()))) {
                String filePath = file.getAbsolutePath();
                if (StringUtils.isNotEmpty(lastPathAfterSeparator)) {
                    lastPathAfterSeparator = file.getAbsolutePath().substring(filePath.lastIndexOf(WINDOWS_SEPARATOR), filePath.length()) + lastPathAfterSeparator;
                } else {
                    lastPathAfterSeparator = file.getAbsolutePath().substring(filePath.lastIndexOf(WINDOWS_SEPARATOR), filePath.length());
                }
                file = file.getParentFile();
            }
            return getWindowsShortPath(file.getAbsolutePath()) + lastPathAfterSeparator;
        }
    }
757637
@SuppressWarnings("unchecked")
	protected <Y> Path<Y> buildPropertyPath(Root<?> root, String stringPath) {
		
		// Si la racine est nulle
		if(root == null) return null;
		
		// Si la chaine est vide
		if(stringPath == null || stringPath.trim().length() == 0) return null;
		
		// Le Path à retournet
		Path<? extends Comparable<?>> path = null;
		
		// On splitte sur le séparateur de champs
		String[] hierarchicalPaths = stringPath.trim().split("\\.");
		
		// Obtention du premier chemin
		path = root.get(hierarchicalPaths[0]);
		
		// Si la taille est > 1
		if(hierarchicalPaths.length > 1) {

			// Parcours
			for (int i = 1; i < hierarchicalPaths.length; i++) {
				
				// Le chemin
				String unitPath = hierarchicalPaths[i];
				
				// Si le path est vide ou est une suite d'espace
				if(unitPath == null || unitPath.trim().length() == 0) continue;
				
				// Acces à la ppt
				path = path.get(unitPath.trim());
			}
		}
		
		// On retourne le Path
		return (Path<Y>) path;
	}
442645
function loadNode(core, rootNode, nodePath) {
        return core.loadByPath(rootNode, nodePath)
            .then(function (node) {
                if (node === null) {
                    throw new Error('Given nodePath does not exist "' + nodePath + '"!');
                } else {
                    return node;
                }
            });
    }
618442
function buildFromDirectory(dirPath){
	var dbsetPath = path.join(dirPath,"dbsets");
	if(fileutil.isExist(dbsetPath)){
		defaultConfig['dbsets'] = dbsetPath;
	}

	var stubsPath = path.join(dirPath,"stubs");
	if(fileutil.isExist(stubsPath)){
		defaultConfig['stubs'] = stubsPath;
	}

	var dumpsPath = path.join(dirPath,"dumps");
	if(fileutil.isExist(dumpsPath)){
		defaultConfig['dumps'] = dumpsPath;
	}

	var mappingsPath = path.join(dirPath,"mappings");
	var files = fileutil.ls(mappingsPath);
	if(files.length > 0){
		defaultConfig['mappings']['requests'] = [];
		files.forEach(function(filename){
			defaultConfig['mappings']['requests'].push(path.join(mappingsPath , filename));
		});
	}

	var trustStorePath = path.join(dirPath,"truststore");
	if(fileutil.isExist(trustStorePath)){
		defaultConfig.server.key = path.join(trustStorePath , "server.key");
		defaultConfig.server.cert = path.join(trustStorePath , "server.crt");

		var cacertPath = path.join(trustStorePath,"ca");
		var cacerts = fileutil.ls(cacertPath);

		if(cacerts.length > 0){
			defaultConfig.server.ca = [];
			cacerts.forEach(function(filename){
				defaultConfig.server.ca.push(path.join(cacertPath , filename));
			});
		}
	}
}
500064
function getServerBuildDirectory(): string {
  // Generate a random string to ensure uniqueness
  const buildToken = crypto.randomBytes(16).toString('hex');
  return path.resolve(os.tmpdir(), `nucleate-${buildToken}`);
}
1193028
function getClosestPackage(modulePath) {
  let root;
  let pkg;

  // Catch findRoot or require errors
  try {
    root = findRoot(modulePath);
    pkg = require(path.join(root, "package.json"));
  } catch (e) {
    return null;
  }

  // If the package.json does not have a name property, try again from
  // one level higher.
  // https://github.com/jsdnxx/find-root/issues/2
  // https://github.com/date-fns/date-fns/issues/264#issuecomment-265128399
  if (!pkg.name) {
    return getClosestPackage(path.resolve(root, ".."));
  }

  return {
    package: pkg,
    path: root
  };
}
1114306
function getSourcepath(filepath, htmlpath, rootpath) {
  if (!filepath) {
    return ['', ''];
  }

  if (isRemoteFilepath(filepath)) {
    const url = new URL(filepath);

    filepath = `./${url.pathname.slice(1).replace(RE_FORWARD_SLASH, '_')}`;
  }
  // Strip query params
  filepath = filepath.replace(RE_QUERY, '');
  // Relative path
  if (htmlpath && isRelativeFilepath(filepath)) {
    filepath = path.resolve(path.dirname(htmlpath), filepath);
    // Strip leading '/'
  } else if (filepath.indexOf('/') == 0) {
    filepath = filepath.slice(1);
  }
  if (filepath.includes('#')) {
    filepath = filepath.split('#');
  }

  return Array.isArray(filepath)
    ? [path.resolve(rootpath, filepath[0]), filepath[1]]
    : [path.resolve(rootpath, filepath), ''];
}
51200
public CmsADEConfigData lookupConfiguration(String rootPath) {

        CmsADEConfigDataInternal internalSiteConfig = getSiteConfigData(rootPath);
        CmsADEConfigData result;
        if (internalSiteConfig == null) {
            result = wrap(m_moduleConfiguration);
        } else {
            result = wrap(internalSiteConfig);
        }
        return result;
    }
659018
function(path, root) {
  return new P(function(resolve, reject) {
    if(isRelativePath(path)) {
      path = isUrl(root) ?
        url.resolve(root, path) :
        join(root, path);
    }

    if(isUrl(path)) {
      request.get(path, {encoding: null}, function(err, response, body) {
        if(err) { return reject(err); }
        return response.statusCode === 200 ?
          resolve(body) :
          reject(new Error('Got status ' + response.statusCode + ' fetching ' + path));
      });
    } else {
      fs.readFile(path, function(err, body) {
        return err ?
          reject(err) :
          resolve(body);
      });
    }
  });
}
720799
private File findPathResource(@NonNull String httpPath) {
        if ("/".equals(httpPath)) {
            File root = new File(mRootPath);
            return root.exists() ? root : null;
        } else {
            File sourceFile = new File(mRootPath, httpPath);
            if (sourceFile.exists()) {
                return sourceFile;
            }
        }
        return null;
    }
196320
private String buildServletPath() {
    String uri = servletPath;
    if (uri == null && null != requestURI) {
      uri = requestURI;
      if (!contextPath.equals("/")) uri = uri.substring(contextPath.length());
    }
    return (null == uri) ? "" : uri;
  }
1048813
private String buildUrl( String methodPath, CPath path )
    {
        StringBuilder sb = new StringBuilder();

        sb.append( END_POINT ).append( '/' ).append( methodPath );

        if ( path != null ) {
            sb.append( '/' ).append( scope ).append( path.getUrlEncoded() );
        }

        return sb.toString();
    }
171549
function (serverPath)
		{
			if (!_.isString(serverPath))
				return false;

			var _sourcePath = cwd+sourcePath,
				relativeSourcePath = path.relative(serverPath,_sourcePath)+'/',
				relativeServerPath = path.relative(cwd,serverPath);

			self.e.log("[*] Building new wnServer on `"+serverPath+"`");

			if (!fs.existsSync(serverPath))
				fs.mkdirSync(serverPath);

			self.e.log("[*] - Creating new `package.js` file.");
			var defaultPackage = fs.readFileSync(_sourcePath+'/default-package.json').toString('utf8');
			defaultPackage = (defaultPackage+'').replace(/\{moduleName\}/g, 'server-'+serverPath.substr(0,serverPath.length-1).split('/').pop().replace(/\s/g,'-'));
			fs.writeFileSync(serverPath+'/package.json',defaultPackage);

			self.e.log("[*] - Creating new `config.json` file.");
			fs.writeFileSync(serverPath+'/config.json',
				fs.readFileSync(_sourcePath+'/default-config.json')
			);

			self.e.log("[*] - Creating new `index.js` file.");
			var defaultIndex = fs.readFileSync(_sourcePath+'/default-index.js').toString('utf8');
			defaultIndex = defaultIndex.replace(/\{sourcePath\}/g,'./'+relativeSourcePath.replace(/\\/g,'/'));
			defaultIndex = defaultIndex.replace(/\{serverPath\}/g,'./'+relativeServerPath.replace(/\\/g,'/'));
			fs.writeFileSync(serverPath+'/index.js',defaultIndex);

			self.e.log('[*] New wnServer created.');

			return true;
		}
171296
function buildRegExps(basePath, dirPaths) {
  return dirPaths.map(folderPath =>
    // Babel cares about windows/unix paths since v7b44
    // https://github.com/babel/babel/issues/8184
    // basePath + path.sep + dirPath/dirRegex
    // /home/name/webroot/js + / + relative/path/to/exclude
    // c:\home\name\webroot\js + \ + relative\path\to\exclude
    folderPath instanceof RegExp
      ? new RegExp(
          `^${escapeRegExp(path.resolve(basePath, '.') + path.sep)}${
            folderPath.source // This is actual regex, don't escape it
          }`,
          folderPath.flags,
        )
      : new RegExp('^' + escapeRegExp(path.resolve(basePath, folderPath))),
  );
}