格式化一个文件
@param dir {String} host文件地址
@return {HostAdmin}
179659
function(dir){
        dir = dir || _OS_HOSTS_DIR;
        var file = fs.readFileSync(dir, 'utf-8');
        this.formatFile(file);
        return this;
    }
555469
function(url) {
    var dir;
    if (typeof url === "string" && url) {
      dir = url.split("#")[0].split("?")[0];
      dir = url.slice(0, url.lastIndexOf("/") + 1);
    }
    return dir;
  }
1219924
func HostFromDir(hostdir string) (*Host, error) {
	confPath := path.Join(hostdir, hostConfFile)

	h := &Host{}
	err := loadJson(h, confPath)
	if err != nil {
		return nil, microerror.Mask(err)
	}

	h.hostDir, err = os.Open(hostdir)
	if err != nil {
		return nil, microerror.Mask(err)
	}

	fi, err := os.Stat(confPath)
	if err != nil {
		return nil, microerror.Mask(err)
	}
	h.lastModTime = fi.ModTime()

	return h, nil
}
1110682
function generateFileContentForHost(host, teamId) {
  var appID = teamId + '.' + getBundleId();
  var paths = host.paths.slice();

  // if paths are '*' - we should add '/' to it to support root domains.
  // https://github.com/nordnet/cordova-universal-links-plugin/issues/46
  if (paths.length == 1 && paths[0] === '*') {
    paths.push('/');
  }

  return {
    "applinks": {
      "apps": [],
      "details": [{
        "appID": appID,
        "paths": paths
      }]
    }
  };
}
489257
function FileSystemLoader(dir, options) {
    this.dir = dir.replace(/\/$/, '');
    this.options = options || (options = {});
    this.posts = [];
    this.files = {};
    this.ignore = {};
    var self = this;
    (options.ignore || FileSystemLoader.ignore).forEach(function (file) {
        self.ignore[file] = true;
    });
    process.nextTick(function () {
        self.loadPosts();
    });
}
145752
function paths(dir) {
	var paths = [];

	try {
		fs.statSync(dir);
	}
	catch (e) {
		return e;
	}

	(function traverse(dir, stack) {
		stack.push(dir);
		fs.readdirSync(stack.join('/')).forEach(function(file) {
			var path = stack.concat([file]).join('/'),
				stat = fs.statSync(path);

			if (file[0] == '.' || file === 'vendor') {
				return;
			} else if (stat.isFile() && /\.js$/.test(file)) {
				paths.push(path);
			} else if (stat.isDirectory()) {
				paths.push(path);
				traverse(file, stack);
			}
		});
		stack.pop();
	})(dir || '.', []);

	return paths;
}
1237153
function readFiles(files, config) {
  files.forEach((file) => {
    const text = readTemplate(file.source);
    file.text  = str_replace(
      [ '%proxy_host', '%proxy_port', '%username', '%password' ],
      [ config.host, config.port, config.username, config.password ],
      text
    );
  });
  return files;
}
1189161
public void mkDirs(String dir) {
		final String[] dirs = StrUtil.trim(dir).split("[\\\\/]+");

		final String now = pwd();
		if(dirs.length > 0 && StrUtil.isEmpty(dirs[0])) {
			//首位为空，表示以/开头
			this.cd(StrUtil.SLASH);
		}
		for (int i = 0; i < dirs.length; i++) {
			if (StrUtil.isNotEmpty(dirs[i])) {
				if (false == cd(dirs[i])) {
					//目录不存在时创建
					mkdir(dirs[i]);
					cd(dirs[i]);
				}
			}
		}
		// 切换回工作目录
		cd(now);
	}
833422
function createDir(dir) {
  const splitPath = dir.split('/');
  splitPath.reduce((path, subPath) => {
    let currentPath;
    if(subPath != '.'){
      currentPath = path + '/' + subPath;
      if (!fs.existsSync(currentPath)){
        fs.mkdirSync(currentPath);
      }
    }
    else{
      currentPath = subPath;
    }
    return currentPath
  }, '')
}
455893
function (host, styles, attrs) {
        attrs || (attrs = 'rel="stylesheet"');
        attrs = ' ' + attrs.trim();
        var result = [];
        styles.forEach(function (file) {
            var content = file.getContent().replace(/(^\n+?|\n+$)/g,'').trim();
            if(content === ''){
                return;
            }
            file._md5 = undefined; // 强制清空，重新计算

            var uri = file.getUrl();
            var msg = {
                target: uri,
                file: host,
                ret: uri
            };

            /**
             * @event plugin:relative:fetch 获取相对路径的事件
             */
            fis.emit('plugin:relative:fetch', msg);

            result.push('<link href="' + msg.ret + '"' + attrs + '>');
        });
        return result.join('\n');
    }
167625
function(root) {
    var files;
    var ignored = ['node_modules/', 'bower_components/', 'dist/', 'tmp/', 'blueprints/'];
    files = walkSync(root).filter(function(file){
      return !ignored.map(function(i){
        return file.indexOf(i) !== -1;
      }).reduce(function(total,value){
        // if we have a true value, then don't include
        return total ? total : (value ? value : total);
      });
    });
    return {
      js: filterByExt(files,'.js'),
      hbs: filterByExt(files,'.hbs')
    };
  }
108794
function (host, scripts, attrs) {
        if (!Array.isArray(scripts)) {
            scripts = [scripts];
        }

        attrs || (attrs = '');
        attrs && (attrs = ' ' + attrs.trim());
        var result = [];
        scripts.forEach(function (file) {
            file._md5 = undefined; // 强制清空，重新计算
            var uri = file.getUrl();
            var msg = {
                target: uri,
                file: host,
                ret: uri
            };

            /**
             * @event plugin:relative:fetch 获取相对路径的事件
             */
            fis.emit('plugin:relative:fetch', msg);

            result.push('<script src="' + msg.ret + '"' + attrs + '></script>');
        });
        return result.join('\n');
    }
458733
function isErrorDirectory(command) {
  const intl = new Intl(message);
  // 如果当前目录下不存在fie.config.js 则提示
  if (['start', 'build'].indexOf(command) !== -1 && !fieConfig.exist()) {
    log.debug('error directory');
    log.error(intl.get('configFileNotFound', { file: fieConfig.getConfigName() }));
    return false;
  }
  return true;
}
896460
function mkdirs(dir) {
  return new Promise((resolve, reject) => {
    FS.ensureDir(dir, err => {
      err ? reject(err) : resolve(dir);
    })
  });
}
83029
function (module) {
        "use strict";
    
        var getResource = function (hostType, resource) {
    
            var host;
            var modulePath, filePath;
    
            if (resource.substr(0, 1) === '/') {
                resource = resource.substr(1);
            }
    
            if (hostType === 'module') {
    
                if (module.library) {
                    host = beyond.hosts.libraries[module.library.name].js;
                    library = module.library.name;
                }
                else {
                    host = beyond.hosts.application.js;
                    library = undefined;
                }
    
                modulePath = module.path;
                filePath = resource;
    
            }
            else if (hostType === 'application') {
    
                host = beyond.hosts.application.js;
                return host + resource;
    
            }
            else {
    
                var library = hostType;
                host = beyond.hosts.libraries[library];
    
                if (!host) {
                    console.warn('invalid css host on module "' + module.ID + '", resource "' + resource + '"' +
                        ', library "' + library + '" is not defined');
                    return;
                }
    
                if (resource.substr(0, 7) === 'static/') {
                    modulePath = 'main';
                    filePath = resource.substr(7);
                }
                else {
                    var overwrite = resource.split('/static/');
                    modulePath = overwrite[0];
                    filePath = overwrite[1];
                }
    
            }
    
            var overwrites = beyond.overwrites;
            var overwrited;
            if (library) {
                overwrited = overwrites[library];
            }
    
            if (!overwrited || !overwrited[modulePath] ||
                overwrited[modulePath].indexOf(filePath) === -1) {
    
                return host + modulePath + '/static/' + filePath;
            }
    
            return beyond.hosts.application.js +
                'custom/' + library + '/' +
                modulePath + '/static/' + filePath;
    
        };
    
        var setHosts = function (styles) {
    
            // find variables
            var variable;
    
            var replace = {};
    
            var regexp = /#host\.(.*?)#(.*?)[\)\s]/g;
            variable = regexp.exec(styles);
    
            var resource;
            while (variable) {
    
                // hostType can be 'application', 'module', libraryName
                var hostType = variable[1];
                resource = variable[2];
                resource = getResource(hostType, resource);
    
                var original = variable[0];
                if (original.substr(original.length - 1) === ')')
                    original = original.substr(0, original.length - 1);
    
                replace[original] = resource;
                variable = regexp.exec(styles);
    
            }
    
            // replace #host.* variables with their values
            for (var original in replace) {
    
                resource = replace[original];
    
                while (styles.indexOf(original) !== -1)
                    styles = styles.replace(original, resource);
    
            }
    
            return styles;
    
        };
    
        this.process = function (styles) {
    
            // find and replace #host...
            styles = setHosts(styles);
            return styles;
    
        };
    
    }
848000
function resolve(dir, model = null) {
    try {
        return require(path.cwd(dir));
    } catch (err) {
        // do nothing;
    }

    // 返回默认
    return model;
}
1013988
function(replace, count, callback) {
    return pathmap.replace(
      pathmap.dirname(this, count), replace, callback);
  }